Skip to content

Commit f55c4d2

Browse files
committed
Add BUILD_OFFLINE capability to skip post-checkout submodule init
Patch by Josh McKenzie; reviewed by David Capwell for CASSANDRA-21364
1 parent 8876ad4 commit f55c4d2

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

.build/git/git-hooks/post-checkout/100-update-submodules.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ _main() {
3131
root_dir="$(git rev-parse --show-toplevel)"
3232
cd "$root_dir"
3333

34-
if [[ ! -e .gitmodules ]]; then
34+
if ! git ls-files --error-unmatch .gitmodules &>/dev/null; then
3535
# nothing to see here, look away!
3636
return 0
3737
fi
38-
git submodule update --init --recursive
38+
39+
local extra_args=()
40+
if [[ -n "${BUILD_OFFLINE:-}" ]]; then
41+
echo "BUILD_OFFLINE is defined; using --no-fetch for submodule updates (local SHAs only)."
42+
echo "If your submodules are not already available locally, expect this to error out."
43+
extra_args+=(--no-fetch)
44+
fi
45+
git submodule update --init --recursive "${extra_args[@]}"
3946
}
4047

4148
_main "$@"

.build/git/git-hooks/pre-commit/100-verify-submodules-pushed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ _main() {
6060
root_dir="$(git rev-parse --show-toplevel)"
6161
cd "$root_dir"
6262

63-
[[ ! -e .gitmodules ]] && return 0
63+
git ls-files --error-unmatch .gitmodules &>/dev/null || return 0
6464
local enabled=$(git config --bool cassandra.pre-commit.verify-submodules.enabled || echo true)
6565
[ "$enabled" == "false" ] && return 0
6666
local submodules=( $(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') )

0 commit comments

Comments
 (0)