Cover the keep gate for unmanaged worktrees
--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:
@@ -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:
|
// A worktree whose directory was deleted leaves only a registration behind:
|
||||||
// there is nothing to lose, so it is prunable outright.
|
// there is nothing to lose, so it is prunable outright.
|
||||||
func TestPruneStaleRegistrationWithMissingDirectory(t *testing.T) {
|
func TestPruneStaleRegistrationWithMissingDirectory(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user