feat(dx): add worktree:sync mise task to rebase clean worktrees on origin/main#218
feat(dx): add worktree:sync mise task to rebase clean worktrees on origin/main#218ClintEastman02 wants to merge 6 commits into
Conversation
…igin/main Worktrees branched from origin/main drift silently as other PRs merge, causing unnecessary conflicts at push time and CI runs against stale bases. Issue aws-samples#197. The new `mise run worktree:sync` task fetches origin/main and rebases every clean linked worktree onto it. Dirty worktrees and main itself are skipped; conflicting rebases are aborted and reported with a non-zero exit so the operator can resolve them explicitly rather than leaving a half-rebased state. Closes aws-samples#197
|
Works as designed. I noticed that the script could be enhanced with a "detect already-merged branches" check (e.g., |
Address review feedback on PR aws-samples#218: detect worktrees whose HEAD is already an ancestor of origin/main (i.e. the branch has merged) and skip them with a MERGED message rather than attempting a no-op rebase. The operator can then prune the worktree at their leisure. Suggested by @scottschreckengaust.
|
Good call — added the merged-branch detection in fe30fb7. Worktrees whose HEAD is already an ancestor of Test matrix (all four cases verified locally):
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #218 +/- ##
=======================================
Coverage ? 85.98%
=======================================
Files ? 167
Lines ? 39535
Branches ? 3795
=======================================
Hits ? 33993
Misses ? 5542
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Adds a new mise task
mise run worktree:syncthat fetchesorigin/mainand rebases every clean linked worktree onto it. Implements Option A from #197.git worktree list --porcelainand rebases each linked worktreeSKIPmessagemain/master(rebase isn't the right tool for the primary branch)git rebase --abortand exits non-zero so the operator surfaces the conflict explicitly rather than leaving a half-rebased stateAlso updates
AGENTS.mdto point contributors at the new task in two places (the worktree common-mistake bullet and the Commands you can use list).Closes #197
Test plan
Tested locally with four worktree states:
origin/main→ rebased successfullyorigin/main→ no-op (rebase reports "up to date")SKIPmessage, not touchedFAILreported,git rebase --abortruns, working tree restored to pre-rebase HEAD, task exits non-zeromainworktree → skipped silentlymise tasks --alllists//:worktree:sync)