Reset main repo to master after non-worktree phase execution#
Problem#
After PhaseRouterService.executePhase() completes a phase that ran in the main repo (no isolated worktree), the repo can be left on a feature branch, causing subsequent phases to start from the wrong branch.
Task / Link#
Closes #267
Changes#
- Added
WorktreeService.resetToMaster(repo)— runsgit checkout masterin the main repo path, catches errors and logs a warning without throwing - Called
resetToMasterinPhaseRouterService.executePhase()finally block when!worktreePath(phase ran in main repo, not a worktree) - Added unit tests: resetToMaster called for non-worktree phases, not called for worktree phases, error is caught and does not propagate
- Added unit tests for
WorktreeService.resetToMaster: correct git command + cwd, and failure is swallowed with a warning
Notes#
If the main repo has uncommitted changes at cleanup time, git checkout master will fail — the error is caught and logged as a warning so the original phase result is not masked.
Testing#
npm run test— 694/694 tests passnpm run lint— zero errors