From f6da41ec8e71790555080f714e773297b27653e9 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 20 May 2024 01:54:22 +0200 Subject: [PATCH] lib: retry git fetch a few times (take 2) Wrap the failure in a if statement. Otherwise it will fail the first time because the script runs under -e --- lib/build.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/build.sh b/lib/build.sh index 5ccc536..11bdf3a 100755 --- a/lib/build.sh +++ b/lib/build.sh @@ -26,9 +26,12 @@ if ! [[ "$ref" =~ ^refs/ ]] ; then ref=refs/heads/$ref fi for retry in 1 2 3 ; do - timeout 15m git fetch --update-head-ok origin +$ref:$ref && break - echo "Retry git fetch in 60 seconds" - sleep 60 + if timeout 15m git fetch --update-head-ok origin +$ref:$ref ; then + break + else + echo "Retry git fetch in 60 seconds" + sleep 60 + fi done git fetch --update-head-ok origin +$ref:$ref git switch --force-create $v $ref