diff --git a/.build/git/git-hooks/post-checkout/100-update-submodules.sh b/.build/git/git-hooks/post-checkout/100-update-submodules.sh index b495ed0860..fdd4618720 100755 --- a/.build/git/git-hooks/post-checkout/100-update-submodules.sh +++ b/.build/git/git-hooks/post-checkout/100-update-submodules.sh @@ -31,11 +31,18 @@ _main() { root_dir="$(git rev-parse --show-toplevel)" cd "$root_dir" - if [[ ! -e .gitmodules ]]; then + if ! git ls-files --error-unmatch .gitmodules &>/dev/null; then # nothing to see here, look away! return 0 fi - git submodule update --init --recursive + + local extra_args=() + if [[ -n "${BUILD_OFFLINE:-}" ]]; then + echo "BUILD_OFFLINE is defined; using --no-fetch for submodule updates (local SHAs only)." + echo "If your submodules are not already available locally, expect this to error out." + extra_args+=(--no-fetch) + fi + git submodule update --init --recursive "${extra_args[@]}" } _main "$@" diff --git a/.build/git/git-hooks/pre-commit/100-verify-submodules-pushed.sh b/.build/git/git-hooks/pre-commit/100-verify-submodules-pushed.sh index ec10bba04a..dbf9ca5563 100755 --- a/.build/git/git-hooks/pre-commit/100-verify-submodules-pushed.sh +++ b/.build/git/git-hooks/pre-commit/100-verify-submodules-pushed.sh @@ -60,7 +60,7 @@ _main() { root_dir="$(git rev-parse --show-toplevel)" cd "$root_dir" - [[ ! -e .gitmodules ]] && return 0 + git ls-files --error-unmatch .gitmodules &>/dev/null || return 0 local enabled=$(git config --bool cassandra.pre-commit.verify-submodules.enabled || echo true) [ "$enabled" == "false" ] && return 0 local submodules=( $(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') )