diff options
author | Joris Roovers <joris.roovers@gmail.com> | 2023-06-02 10:47:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-02 10:47:19 +0200 |
commit | 2970c1986696f1ba853622a597937ac9bacec497 (patch) | |
tree | c834e17e7906bfc7dd316baff3cb6807c6c1c3cd | |
parent | 8aad66f82722244caf7b4fce06821491186d8d1c (diff) |
tools/create-test-repo.sh: use subshell (#500)
tools/create-test-repo.sh will now enter a subshell
immediately inside the temporary git repo directory, and reconfigure
hatch to be able to run from that that directory.
This avoids developers having to manually type the cd command to enter
the correct temp repo after creation and having to reconfigure hatch.
-rwxr-xr-x | tools/create-test-repo.sh | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/tools/create-test-repo.sh b/tools/create-test-repo.sh index 5fddf8c..854a6c5 100755 --- a/tools/create-test-repo.sh +++ b/tools/create-test-repo.sh @@ -6,12 +6,14 @@ BLUE="\033[94m" GREEN="\033[32m" NO_COLOR="\033[0m" -CWD="$(pwd)" -echo "pwd=$CWD" +GITLINT_DIR=$(pwd) + # Create the repo +echo -e "${YELLOW}Creating new temp repo...${NO_COLOR}" cd /tmp reponame=$(date +gitlint-test-%Y-%m-%d_%H-%M-%S) git init --initial-branch main $reponame + cd $reponame # Do some basic config @@ -25,11 +27,21 @@ echo "tëst 123" > test.txt git add test.txt # commit -m -> use multiple -m args to add multiple paragraphs (/n in strings are ignored) git commit -m "test cömmit title" -m "test cömmit body that has a bit more text" -cd $CWD + + +echo -e "${YELLOW}Reconfiguring hatch...${NO_COLOR}" +hatch config set projects.gitlint $GITLINT_DIR + # Let the user know +echo -e "${YELLOW}All Done!${NO_COLOR}" echo "" -echo -e "Created $GREEN/tmp/${reponame}$NO_COLOR" -echo "Hit key up to access 'cd /tmp/$reponame'" -echo "(Run this script using 'source' for this to work)" -history -s "cd /tmp/$reponame" +echo -e "Entering subshell at $GREEN/tmp/${reponame}$NO_COLOR. Type 'exit' to exit." + +rcfile=""" +source ~/.bash_profile; +cd /tmp/$reponame; +alias gitlint='HATCH_PROJECT=gitlint hatch run dev:gitlint --target /tmp/$reponame' +""" + +bash --rcfile <(echo "$rcfile")
\ No newline at end of file |