Skip to content

Commit 3dd75a7

Browse files
committed
test(external): initialise submodules in external fixture clones
1 parent d70dc79 commit 3dd75a7

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

scripts/external-repos-lib.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,21 @@
1111
# Pinned commits make the integration tests reproducible across upstream
1212
# pushes; unpinned URLs follow upstream HEAD.
1313

14+
# Initialise any submodules of $1 (shallow, recursive). No-op when the repo
15+
# declares none. Some mods vendor shared libraries (e.g. BGforge-MLS-IElib) as
16+
# submodules, and their sources are part of the real-world corpus the
17+
# integration tests sweep.
18+
init_submodules() {
19+
local repo_dir="$1"
20+
if [[ -f "$repo_dir/.gitmodules" ]]; then
21+
git -C "$repo_dir" submodule update --init --recursive --depth 1 -q
22+
fi
23+
}
24+
1425
# Clone each repo listed in $1 into $2.
1526
# If a target directory already exists, leave its checkout alone - callers
16-
# rely on this for the "already cloned" optimisation.
27+
# rely on this for the "already cloned" optimisation. Submodules are still
28+
# initialised on that path so pre-existing checkouts converge with fresh ones.
1729
clone_repos() {
1830
local txt_file="$1"
1931
local target_dir="$2"
@@ -28,6 +40,7 @@ clone_repos() {
2840

2941
if [[ -d "$target_dir/$name" ]]; then
3042
echo " Already cloned: $name"
43+
init_submodules "$target_dir/$name"
3144
continue
3245
fi
3346

@@ -41,6 +54,7 @@ clone_repos() {
4154
echo " Cloning: $name (HEAD)"
4255
git clone --depth 1 -q "$url" "$target_dir/$name"
4356
fi
57+
init_submodules "$target_dir/$name"
4458
done <"$txt_file"
4559
}
4660

scripts/reset-external.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ fi
2323
for dir in "$ROOT_DIR"/external/fallout/*/ "$ROOT_DIR"/external/infinity-engine/*/; do
2424
if [[ -d "$dir/.git" ]]; then
2525
git -C "$dir" checkout . 2>/dev/null || true
26+
# Submodule worktrees are separate repos; the checkout above does not
27+
# touch them, so reset each initialised one as well.
28+
git -C "$dir" submodule foreach --recursive --quiet 'git checkout . 2>/dev/null || true' 2>/dev/null || true
2629
fi
2730
done
2831

0 commit comments

Comments
 (0)