Try a clean git-clone if pulling fails

This commit is contained in:
maride 2023-10-14 15:31:43 +02:00
parent 0d7b92f3d2
commit 4c22604a83

View File

@ -15,6 +15,15 @@ set -e -v
true true
else else
# repo URL set # repo URL set
if [ -d /repo ]; then
# repo already exists, try to pull
cd /repo && git pull --recurse-submodules
if [ "$?" -ne 0 ]; then
# pull failed, clean and retry to clone
echo "Pull failed, attempting to clean clone"
rm -rf /repo
fi
fi
if [ ! -d /repo ]; then if [ ! -d /repo ]; then
# repo needs to be cloned # repo needs to be cloned
# check if there is a specific branch to clone # check if there is a specific branch to clone
@ -22,9 +31,6 @@ set -e -v
BRANCHCMD="--branch $REPO_BRANCH" BRANCHCMD="--branch $REPO_BRANCH"
fi fi
git clone --recurse-submodules $BRANCHCMD $REPO_URL /repo git clone --recurse-submodules $BRANCHCMD $REPO_URL /repo
else
# no - pull existing repo
cd /repo && git pull --recurse-submodules
fi fi
fi fi