Skip to content
Snippets Groups Projects
Verified Commit 4db7c0ec authored by mielimom02's avatar mielimom02
Browse files

feat(git): modified the fugit.sh script to allow cloning and running on...

feat(git):  modified the fugit.sh script to allow cloning and running on andorra as well as switching between make, python and node
parent 9b305a15
No related branches found
No related tags found
No related merge requests found
#!/bin/sh #!/bin/sh
if [ $# -gt 2 ]; then if [ $# -gt 2 ] || [ "$1" = "--help" ]; then
printf "Usage: %s [branch] [reponame]" $(basename $0) >&2 printf "Usage: %s [branch] [reponame]\n" $(basename $0) >&2
printf "Default branch name will be read from comments.txt" >&2 printf "Default branch name will be read from comments.txt\n" >&2
printf "Default reponame will be npvp-exercises" >&2 printf "Default reponame will be npvp-exercises\n" >&2
printf "set env:FU_ANDORRA_USER and optionally env:FU_ANDORRA_DIR to checkout and run on andorra automatically\n" >&2
printf "if env:FU_ANDORRA_DIR is not set, a npvp-tmp dir will be created in your main dir\n" >&2
printf "set env:FU_RUN={0,1,2} to 0 = make, 1 = python, 3 = nodejs\n when running on andorra (default is make)\n" >&2
exit 1 exit 1
fi fi
...@@ -22,4 +25,26 @@ else ...@@ -22,4 +25,26 @@ else
branch_name=$1 branch_name=$1
fi fi
`git clone -b $branch_name git@git.imp.fu-berlin.de:$repo_name git-solution` case ${FU_RUN:-0} in
1)
run_cmd="python3 main.py"
;;
2)
run_cmd="node main.js" # i hope this is correct, we will see when the sheet are finalised.
;;
*)
run_cmd="make run"
;;
esac
if ! [ -z $FU_ANDORRA_USER ]; then
# FU_ANDORRA_USER is set, executing on andorra
clone_dir=${FU_ANDORRA_DIR:-npvp-tmp}
`ssh $FU_ANDORRA_USER@andorra.imp.fu-berlin.de \
"git clone -b $branch_name git@git.imp.fu-berlin.de:$repo_name ./$clone_dir || exit 1; cd $clone_dir && $run_cmd; cd .. && rm -rf $clone_dir"`
else
# run locally:
git clone -b $branch_name git@git.imp.fu-berlin.de:$repo_name git-solution || exit 1
cd git-solution && `$run_cmd`; cd ..
fi
...@@ -2,7 +2,12 @@ ...@@ -2,7 +2,12 @@
# this script cleans all checked out repositories when called from the same folder that contains the grades.csv # this script cleans all checked out repositories when called from the same folder that contains the grades.csv
# or a singular checked out repo when called from within a student folder # or a singular checked out repo when called from within a student folder
if [ -z $FU_ANDORRA_USER ]; then
# only clean up when not run on ssh
# ssh cleans up itself :)
find -type d \ find -type d \
-wholename "*/git-solution" -prune \ -wholename "*/git-solution" -prune \
-execdir sh -c "rm -rf ./git-solution/" {} \; -execdir sh -c "rm -rf ./git-solution/" {} \;
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment