Skip to content

Commit 52cf9e4

Browse files
centdixclaude
andcommitted
refactor: address review feedback on stale-worktree fix
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b7b4d4b commit 52cf9e4

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

backend/src/adapters/git.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function spawnGit(args: string[], cwd: string): { ok: true; result: Bun.SyncSubp
9696
};
9797
} catch (error) {
9898
// Bun.spawnSync throws synchronously when cwd doesn't exist (posix_spawn ENOENT).
99-
return { ok: false, stderr: `spawn failed (cwd=${cwd}): ${errorMessage(error)}` };
99+
return { ok: false, stderr: `spawn error (cwd=${cwd}): ${errorMessage(error)}` };
100100
}
101101
}
102102

backend/src/services/lifecycle-service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,9 @@ export class LifecycleService {
517517
}
518518

519519
private listCheckedOutBranches(): Set<string> {
520+
// Raw listWorktrees on purpose: a stale registration still holds its branch
521+
// in git's view, so it must continue to block branch reuse. Switching this
522+
// to listLiveWorktrees would falsely report the branch as free.
520523
return new Set(
521524
this.deps.git.listWorktrees(resolve(this.deps.projectRoot))
522525
.filter((entry): entry is GitWorktreeEntry & { branch: string } => !entry.bare && entry.branch !== null)

backend/src/services/linear-auto-create-service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ async function runAutoCreate(deps: LinearAutoCreateDependencies): Promise<void>
4545
}
4646

4747
const projectRoot = deps.projectRoot;
48+
// Raw listWorktrees on purpose: a stale registration still holds its branch
49+
// in git's view, so we must treat it as taken to avoid re-creating a worktree
50+
// for an already-registered branch. listLiveWorktrees would skip it.
4851
const existingBranches = deps.git
4952
.listWorktrees(projectRoot)
5053
.filter((entry) => !entry.bare && entry.branch !== null)

0 commit comments

Comments
 (0)