Cover the keep gate for unmanaged worktrees
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful

--include-unmanaged lifts only the location gate, and nothing proved the keep
gate still held behind it.

- assert a dirty hand-made worktree survives --include-unmanaged alone
This commit is contained in:
2026-09-12 00:40:12 +10:00
parent 62aeaf063b
commit 72a8923c3d
+17
View File
@@ -746,6 +746,23 @@ func TestPruneRemovesUnmanagedWorktreeWithFlag(t *testing.T) {
}
}
// --include-unmanaged only lifts the location gate. A keep verdict is a separate
// gate, so a dirty hand-made worktree still needs --include-keep to be touched.
func TestPruneIncludeUnmanagedStillObeysKeep(t *testing.T) {
f := newFixture(t)
manual := f.addManualWorktree(t, "benvin/by-hand")
if err := os.WriteFile(filepath.Join(manual, "scratch.txt"), []byte("wip\n"), 0o644); err != nil {
t.Fatal(err)
}
srv := fakeGitea(t)
out := runOpts(t, client(srv), pruneOpts{apply: true, includeUnmanaged: true})
assertVerdict(t, out, "benvin/by-hand", verdictKeep, "dirty")
if !exists(filepath.Join(manual, "scratch.txt")) {
t.Error("--include-unmanaged must not remove a worktree classified keep")
}
}
// A worktree whose directory was deleted leaves only a registration behind:
// there is nothing to lose, so it is prunable outright.
func TestPruneStaleRegistrationWithMissingDirectory(t *testing.T) {