Find every stale worktree, not just the managed ones #14

Merged
benvin merged 3 commits from benvin/worktree-gc into main 2026-09-12 00:46:40 +10:00
Showing only changes of commit 72a8923c3d - Show all commits
+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) {