(t *testing.T)
| 2065 | } |
| 2066 | |
| 2067 | func TestClientWorktreePruneRemovesMissingWorktreeMetadata(t *testing.T) { |
| 2068 | // Given a linked worktree whose directory was removed outside Git |
| 2069 | repo := newTestRepo(t) |
| 2070 | repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "initial commit") |
| 2071 | repo.run(t, "branch", "feature") |
| 2072 | worktreeDir := filepath.Join(t.TempDir(), "feature") |
| 2073 | repo.run(t, "worktree", "add", "--quiet", worktreeDir, "feature") |
| 2074 | require.NoError(t, os.RemoveAll(worktreeDir)) |
| 2075 | |
| 2076 | // When stale worktree metadata is pruned |
| 2077 | err := repo.client.WorktreePrune(t.Context()) |
| 2078 | |
| 2079 | // Then the missing worktree is no longer listed |
| 2080 | require.NoError(t, err) |
| 2081 | worktrees, listErr := repo.client.Worktrees(t.Context()) |
| 2082 | require.NoError(t, listErr) |
| 2083 | assert.Nil(t, WorktreeForBranch(worktrees, "feature")) |
| 2084 | } |
nothing calls this directly
no test coverage detected