File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments