Plan: Worktree branches from RC branch during release#
Summary#
Add a baseBranch parameter to WorktreeService.getOrCreateWorktree() so worktrees are created from origin/{rcBranch} when a task belongs to an active release. In PhaseRouterService.executePhase(), look up the active release config and pass the RC branch to the worktree call.
Files#
| File | Action | Description |
|---|---|---|
src/worktree/worktree.service.ts | modify | Add optional baseBranch parameter (default 'master'), use it in git worktree add |
src/phase-router/phase-router.service.ts | modify | Look up release config before worktree creation, pass rcBranch as baseBranch |
src/worktree/worktree.service.spec.ts | modify | Add tests for baseBranch parameter in getOrCreateWorktree() |
src/phase-router/phase-router.service.spec.ts | modify | Add test: release-active task passes rcBranch to worktree; no-release task defaults to master |
Steps#
- Add
baseBranch = 'master'as 4th optional parameter togetOrCreateWorktree()inworktree.service.ts. Replace hardcoded'origin/master'on line 130 with\origin/${baseBranch}``. - In
phase-router.service.tsexecutePhase(), before thegetOrCreateWorktree()call (line 445), look up the release config viathis.releaseService.findActiveForTask(task.id). If active, passreleaseConfig.rcBranchas thebaseBranchparameter. - Add unit tests in
worktree.service.spec.ts: (a) new worktree with custombaseBranchusesorigin/{baseBranch}instead oforigin/master; (b) omittedbaseBranchdefaults toorigin/master(existing tests cover this). - Add unit tests in
phase-router.service.spec.ts: (a) whenreleaseService.findActiveForTaskreturns a release,getOrCreateWorktreeis called withrcBranch; (b) when it returns null,getOrCreateWorktreeis called withoutbaseBranch(defaults to master).
Verification#
npm run testpasses with new and existing testsnpm run lintpasses with zero warnings- Manual inspection:
git worktree addcommand in the fresh-create path usesorigin/{baseBranch}instead of hardcodedorigin/master
Risks#
- Existing worktrees already branched from master are reused as-is (get-or-create pattern, line 92–94). This is by design per the issue's edge case spec — no silent re-creation.
- If the RC branch does not exist on origin,
git worktree addfails naturally — this is correct behavior per the issue spec (misconfigured release).