Skip to content

Commit be03805

Browse files
author
Amna Akram
authored
Update checkout.bats
1 parent bcce8a9 commit be03805

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/checkout.bats

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,25 @@ setup() {
142142
unstub ssh-keyscan
143143
unstub git
144144
}
145+
146+
@test "Clean checkout handles repository without HEAD gracefully" {
147+
export BUILDKITE_PLUGIN_SPARSE_CHECKOUT_CLEAN_CHECKOUT="true"
148+
149+
stub ssh-keyscan "* : echo 'keyscan'"
150+
stub git "reset --hard HEAD : exit 1" # simulate failure
151+
stub git "clean -ffxdq : echo 'git clean'"
152+
stub git "sparse-checkout disable : echo 'sparse-checkout disable'"
153+
stub git "fetch --depth 1 origin * : echo 'git fetch'"
154+
stub git "sparse-checkout set * * : echo 'git sparse-checkout'"
155+
stub git "checkout * : echo 'checkout'"
156+
157+
run "$PWD"/hooks/checkout
158+
159+
assert_success
160+
assert_output --partial 'Clean checkout enabled - resetting repository state'
161+
assert_output --partial 'git clean'
162+
assert_output --partial 'sparse-checkout disable'
163+
164+
unstub ssh-keyscan
165+
unstub git
166+
}

0 commit comments

Comments
 (0)