Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
fix: retry git submodule fetch (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad authored Aug 2, 2023
1 parent e843914 commit 0fcc7d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/init_submodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ set -euo pipefail
REPOSITORY=$1

BUILD_DIR=$(query_manifest buildDir $REPOSITORY)
if [ -d "$BUILD_DIR" ]; then
if [ -d "$BUILD_DIR" ] && [ "$(git submodule status $BUILD_DIR)" ]; then
# We have submodules, initialize them
echo "Initialising any submodules under $REPOSITORY buildDir: $BUILD_DIR"
git submodule update --init --recursive $BUILD_DIR && exit || echo "No submodules under buildDir"
retry_10 git submodule update --init --recursive $BUILD_DIR && exit
fi

SUBMODULE_PATH=$(query_manifest submodulePath $REPOSITORY)
if [ -n "$SUBMODULE_PATH" ]; then
# TODO: Needs to actually init all dependency submodules as well.
echo "Initialising submodule: $SUBMODULE_PATH"
git submodule update --init --recursive $SUBMODULE_PATH
fi
retry_10 git submodule update --init --recursive $SUBMODULE_PATH
fi
7 changes: 7 additions & 0 deletions scripts/retry_10
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set -eu
# Retries up to 10 times with 10 second intervals
for i in $(seq 1 10); do
"$@" && return || sleep 10
done
echo "$@ failed after 10 attempts"
exit 1

0 comments on commit 0fcc7d1

Please sign in to comment.