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

fix: retry git submodule fetch #18

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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