From 872e4632bf433cfa29367760a7cac25d522807d4 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 19 May 2024 09:15:40 +0200 Subject: [PATCH] lib: retry git fetch a few times The instance hosting the forgejo repository may be down or very slow while the build tries to fetch from it, retry a few times instead of giving up immediately. A total retry time of 3 * 60 seconds is probably sufficient since Forgejo startup time is lower than this, even on large instances. --- lib/build.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/build.sh b/lib/build.sh index 9ad74ec..5ccc536 100755 --- a/lib/build.sh +++ b/lib/build.sh @@ -25,6 +25,11 @@ fi 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 +done git fetch --update-head-ok origin +$ref:$ref git switch --force-create $v $ref