From 193e0932d4b58551b0adf6cfca3289a06023acbc Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum <39048939+jnussbaum@users.noreply.github.com> Date: Wed, 23 Nov 2022 16:11:25 +0100 Subject: [PATCH] fix(start-app, start-api): make git handling more robust (DEV-1520) #258 --- knora/dsplib/utils/start-api.sh | 7 +++++++ knora/dsplib/utils/start-app.sh | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/knora/dsplib/utils/start-api.sh b/knora/dsplib/utils/start-api.sh index c7df09609..5d7e00a2d 100755 --- a/knora/dsplib/utils/start-api.sh +++ b/knora/dsplib/utils/start-api.sh @@ -32,13 +32,20 @@ if [[ ! -d dsp-api ]]; then fi cd dsp-api rm -f "$logfile" + echo "make stack-down-delete-volumes..." 2>&1 | tee -a "$logfile" make stack-down-delete-volumes >>"$logfile" 2>&1 + if echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 -w 10 > /dev/null 2>&1; then # only pull if there is an internet connection + echo "git reset --hard HEAD ..." 2>&1 | tee -a "$logfile" + git reset --hard HEAD >>"$logfile" 2>&1 + echo "git checkout main ..." 2>&1 | tee -a "$logfile" + git checkout main >>"$logfile" 2>&1 echo "git pull ..." 2>&1 | tee -a "$logfile" git pull >>"$logfile" 2>&1 fi + echo "make init-db-test..." 2>&1 | tee -a "$logfile" make init-db-test >>"$logfile" 2>&1 echo "make stack-up..." 2>&1 | tee -a "$logfile" diff --git a/knora/dsplib/utils/start-app.sh b/knora/dsplib/utils/start-app.sh index c03c1c339..c559b209b 100755 --- a/knora/dsplib/utils/start-app.sh +++ b/knora/dsplib/utils/start-app.sh @@ -27,8 +27,11 @@ rm -f "$logfile" if echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 -w 10 > /dev/null 2>&1; then # only pull if there is an internet connection + echo "git reset --hard HEAD ..." 2>&1 | tee -a "$logfile" + git reset --hard HEAD >>"$logfile" 2>&1 + echo "git checkout main ..." 2>&1 | tee -a "$logfile" + git checkout main >>"$logfile" 2>&1 echo "git pull ..." 2>&1 | tee -a "$logfile" - git checkout HEAD package-lock.json >>"$logfile" 2>&1 git pull >>"$logfile" 2>&1 fi