Skip to content

Commit 10d71dc

Browse files
committed
fix: detect shallow state via git instead of .git/shallow
1 parent a278da1 commit 10d71dc

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

scripts/ensure_history.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ emit_output() {
1414
fi
1515
}
1616

17-
shallow_file() {
18-
git rev-parse --git-path shallow
19-
}
20-
2117
is_shallow_clone() {
22-
[[ -f "$(shallow_file)" ]]
18+
[[ "$(git rev-parse --is-shallow-repository)" == "true" ]]
2319
}
2420

2521
has_commit() {

tests/test_ensure_history.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ run_history_check() {
2929
)
3030
}
3131

32+
repo_is_shallow() {
33+
local repo="$1"
34+
[[ "$(git -C "$repo" rev-parse --is-shallow-repository)" == "true" ]]
35+
}
36+
3237
test_raw_sha_fetch_stays_shallow() {
3338
init_remote_repo raw-sha
3439
local remote="$INIT_REMOTE"
@@ -57,7 +62,7 @@ test_raw_sha_fetch_stays_shallow() {
5762
run_history_check "$clone" "$base_sha" "$output_file"
5863

5964
git -C "$clone" rev-parse --verify "$base_sha^{commit}" >/dev/null
60-
[[ -f "$(git -C "$clone" rev-parse --git-path shallow)" ]]
65+
repo_is_shallow "$clone"
6166
grep -qx 'shallow=true' "$output_file"
6267
}
6368

@@ -96,7 +101,7 @@ test_branch_ref_falls_back_to_full_history() {
96101

97102
git -C "$clone" rev-parse --verify "origin/main^{commit}" >/dev/null
98103
git -C "$clone" merge-base HEAD origin/main >/dev/null
99-
[[ ! -f "$(git -C "$clone" rev-parse --git-path shallow)" ]]
104+
[[ "$(git -C "$clone" rev-parse --is-shallow-repository)" == "false" ]]
100105
grep -qx 'shallow=true' "$output_file"
101106
}
102107

0 commit comments

Comments
 (0)