diff --git a/src/server/workspaces/gitWorktreeDiscovery.test.ts b/src/server/workspaces/gitWorktreeDiscovery.test.ts index 6feb326..3147261 100644 --- a/src/server/workspaces/gitWorktreeDiscovery.test.ts +++ b/src/server/workspaces/gitWorktreeDiscovery.test.ts @@ -38,15 +38,17 @@ describe("parseGitWorktreeList", () => { ]); }); - it("reports prunable with its reason and locked with or without a reason", () => { + it("reports prunable, and leaves a locked worktree looking like the usable checkout it is", () => { expect(parseGitWorktreeList(removedAndLocked)).toEqual([ { path: "/repo", branch: "main" }, { path: "/repo-worktrees/gone", branch: "gone", prunable: true }, - { path: "/repo-worktrees/kept", branch: "kept", locked: true }, + // `locked` is ignored: a locked worktree is a real checkout and stays a usable + // workspace, so nothing downstream needs to distinguish it. + { path: "/repo-worktrees/kept", branch: "kept" }, ]); const bareLocked = ["worktree /repo-worktrees/kept", "HEAD abc", "detached", "locked", ""].join("\n"); - expect(parseGitWorktreeList(bareLocked)).toEqual([{ path: "/repo-worktrees/kept", detached: true, locked: true }]); + expect(parseGitWorktreeList(bareLocked)).toEqual([{ path: "/repo-worktrees/kept", detached: true }]); }); it("reads bare repositories and ignores chunks without a worktree path", () => { diff --git a/src/server/workspaces/gitWorktreeDiscovery.ts b/src/server/workspaces/gitWorktreeDiscovery.ts index e20a656..8a8524a 100644 --- a/src/server/workspaces/gitWorktreeDiscovery.ts +++ b/src/server/workspaces/gitWorktreeDiscovery.ts @@ -11,8 +11,6 @@ export interface GitWorktreeInfo { detached?: boolean; /** Git reports a linked worktree as prunable when its checkout directory no longer exists. */ prunable?: boolean; - /** Git reports a locked worktree with a bare `locked` line, optionally followed by a reason. */ - locked?: boolean; } export async function isGitRepository(path: string): Promise { @@ -46,7 +44,6 @@ export function parseGitWorktreeList(stdout: string): GitWorktreeInfo[] { if (key === "bare") info.bare = true; if (key === "detached") info.detached = true; if (key === "prunable") info.prunable = true; - if (key === "locked") info.locked = true; } return info; }).filter((w) => w.path); diff --git a/src/server/workspaces/workspaceService.test.ts b/src/server/workspaces/workspaceService.test.ts index d3b9b49..91e2c6a 100644 --- a/src/server/workspaces/workspaceService.test.ts +++ b/src/server/workspaces/workspaceService.test.ts @@ -31,10 +31,10 @@ describe("WorkspaceService.list", () => { expect(workspaces.map((workspace) => workspace.path)).toEqual(["/repo", "/repo-worktrees/live"]); }); - it("keeps a locked worktree, which is still a real checkout", async () => { + it("keeps a worktree that is present but not prunable, such as a locked one", async () => { const service = serviceFor([ { path: "/repo", branch: "main" }, - { path: "/repo-worktrees/kept", branch: "kept", locked: true }, + { path: "/repo-worktrees/kept", branch: "kept" }, ]); const workspaces = await service.list(project);