Skip to content

fix(#295): Rebase worktrees onto main before PR to prevent lockfile drift - #297

Closed
admarble wants to merge 2 commits into
mainfrom
feature/295-fix-rebase-worktrees-onto-main-before-pr-to-preven
Closed

admarble wants to merge 2 commits into
mainfrom
feature/295-fix-rebase-worktrees-onto-main-before-pr-to-preven

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Add pre-PR rebase step: worktree branches are rebased onto origin/main before PR creation
  • Add lockfile change detection and automatic dependency reinstall after rebase
  • Add graceful conflict handling (abort, warn, continue)
  • Add --no-rebase flag to skip pre-PR rebase when preferred

Acceptance Criteria Coverage

AC Description Status Evidence
AC-1 Non-chain mode rebases onto origin/main before PR ✅ Implemented rebaseBeforePR() called in runIssueWithLogging()
AC-2 Chain mode rebases final branch onto origin/main before PR ✅ Implemented Same function, works for all modes
AC-3 After rebase, lockfile change triggers reinstall ✅ Implemented reinstallIfLockfileChanged() checks all lockfiles
AC-4 Rebase conflicts handled gracefully ✅ Implemented Conflict detection, abort, warn, continue pattern
AC-5 --no-rebase flag available ✅ Implemented CLI flag added to bin/cli.ts

Test plan

  • All existing tests pass (1251 tests)
  • New tests for rebaseBeforePR() function
  • New tests for reinstallIfLockfileChanged() function
  • Tests for conflict handling
  • Tests for fetch failure handling

Files Changed

  • bin/cli.ts - Added --no-rebase CLI flag
  • src/commands/run.ts - Added rebaseBeforePR() and reinstallIfLockfileChanged() functions
  • src/commands/run.test.ts - Added tests for new functions

Closes #295

🤖 Generated with Claude Code

…rift

- Add pre-PR rebase step: worktree branches are rebased onto origin/main
  before PR creation (AC-1, AC-2)
- Add lockfile change detection: after rebase, if any lockfile changed
  (package-lock.json, pnpm-lock.yaml, bun.lock, yarn.lock), dependencies
  are automatically reinstalled (AC-3)
- Handle rebase conflicts gracefully: on conflict, abort rebase, warn user,
  and continue with original branch state (AC-4)
- Add --no-rebase flag to skip pre-PR rebase when manual handling preferred (AC-5)
- Add tests for rebaseBeforePR and reinstallIfLockfileChanged functions

Closes #295
… detection

Two QA gaps fixed:

AC-2: In chain mode, only the last issue now triggers rebaseBeforePR.
Intermediate branches stay based on their predecessor, preserving the
chain structure. Added isLastInChain parameter to runIssueWithLogging.

AC-3: Lockfile change detection now uses ORIG_HEAD..HEAD instead of
HEAD~1. After a multi-commit rebase, ORIG_HEAD captures all changes
the rebase introduced (including lockfile updates from main that
appeared in the base, not in replayed commits).

Also replaced tautological lockfile detection test with one that
verifies the correct git ref is used.
@admarble admarble closed this Feb 19, 2026
@admarble
admarble deleted the feature/295-fix-rebase-worktrees-onto-main-before-pr-to-preven branch February 19, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Rebase worktrees onto main before PR to prevent lockfile drift

1 participant