Skip to content

feat(reorder): add squash/fixup commands and autosquash for fixup! commits#709

Merged
aviator-app[bot] merged 8 commits intoaviator-co:masterfrom
amartani:feat/reorder-squash-fixup
Apr 23, 2026
Merged

feat(reorder): add squash/fixup commands and autosquash for fixup! commits#709
aviator-app[bot] merged 8 commits intoaviator-co:masterfrom
amartani:feat/reorder-squash-fixup

Conversation

@amartani
Copy link
Copy Markdown
Contributor

@amartani amartani commented Apr 7, 2026

Add squash (s) and fixup (f) commands to av reorder, matching git rebase -i behavior. squash folds the cherry-picked commit into the previous one and opens the editor with combined messages; fixup does the same but silently keeps the previous commit's message.

Commits created with git commit --fixup (fixup! prefix) or git commit --squash (squash! prefix) are automatically repositioned after their target commit and pre-assigned the appropriate action when the plan is generated, matching git's --autosquash behavior.

Also handles conflict continuation correctly: when av reorder --continue is run after a squash/fixup conflict, the folding step is performed before advancing past the interrupted command.

Fixes #706

…mmits

Add squash (s) and fixup (f) commands to av reorder, matching git
rebase -i behavior. squash folds the cherry-picked commit into the
previous one and opens the editor with combined messages; fixup does
the same but silently keeps the previous commit's message.

Commits created with git commit --fixup (fixup! prefix) or
git commit --squash (squash! prefix) are automatically repositioned
after their target commit and pre-assigned the appropriate action
when the plan is generated, matching git's --autosquash behavior.

Also handles conflict continuation correctly: when av reorder
--continue is run after a squash/fixup conflict, the folding step
is performed before advancing past the interrupted command.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app Bot commented Apr 7, 2026

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged using Aviator.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for squash and fixup commands within the reorder workflow, including an "autosquash" feature that automatically reorders commits with "fixup!" or "squash!" prefixes. The changes include updates to the command parser, the addition of a PerformSquash method to handle commit amending via git reset --soft, and logic in the plan generation to support automatic reordering. Feedback was provided regarding the PerformSquash implementation, specifically noting that it should strip comment lines from the edited commit message to align with standard Git behavior.

Comment thread internal/reorder/pick.go
amartani and others added 2 commits April 7, 2026 15:04
golangci-lint v2.10.1 nolintlint no longer accepts //nolint: <linter>
(with space); use //nolint:<linter> instead.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Track SquashPending in Continuation so --continue only calls
  PerformSquash when a squash/fixup was actually interrupted, preventing
  double-squash when users resolve conflicts manually
- Guard PerformSquash against squash/fixup as first commit in a branch
- Fix os.Stat calls to distinguish IsNotExist from real filesystem errors
- Add explicit switch with default error case in PerformSquash to reject
  unknown PickMode values
- Return ErrInterruptReorder (with --continue hint) when squash message
  is empty, instead of hard-failing and losing reorder state
- Wrap git reset/amend errors with commit hash and mode for context
- Wrap getCommitMessage errors with the failing revision
- Annotate unmatched fixup!/squash! commits with a visible warning in
  the reorder editor
- Add behavioral tests: PerformSquash fixup path, first-commit guard,
  JSON round-trip for squash/fixup modes, Execute fixup mode, and
  autosquash edge cases (fixup before target, mixed fixup+squash)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@amartani amartani marked this pull request as ready for review April 8, 2026 19:17
@amartani amartani requested a review from a team as a code owner April 8, 2026 19:17
@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app Bot commented Apr 8, 2026

✅ FlexReview Status

Common Owner: aviator-co/engineering (expert-load-balance assignment)
Owner and Assignment:

  • 🔒 aviator-co/engineering (expert-load-balance assignment)
    Owned Files
    • 🔒 cmd/av/reorder.go
    • 🔒 internal/reorder/cmds.go
    • 🔒 internal/reorder/cmds_test.go
    • 🔒 internal/reorder/editor.go
    • 🔒 internal/reorder/parse.go
    • 🔒 internal/reorder/parse_test.go
    • 🔒 internal/reorder/pick.go
    • 🔒 internal/reorder/pick_test.go
    • 🔒 internal/reorder/plan.go
    • 🔒 internal/reorder/plan_test.go
    • 🔒 internal/reorder/reorder.go
    • 🔒 internal/reorder/reorder_test.go
    • 🔒 internal/reorder/stackbranch.go
    • 🔒 docs/internal/md2man/roff.go

Review SLO: 7 business hours if PR size is <= 200 LOC for the first response.
❕ This PR modifies 690 lines, which is larger than the Review SLO threshold.

@aviator-app aviator-app Bot requested a review from jainankit April 8, 2026 19:18
@jainankit jainankit requested a review from draftcode April 10, 2026 21:49
amartani and others added 2 commits April 12, 2026 12:19
…oundaries

Replace per-branch autosquashPickCmds with a global autosquashCmds that
operates on the full []Cmd slice. This allows a fixup!/squash! commit in
one branch to be moved right after its target commit in any other branch
of the stack, rather than being left at the end of the branch it
originated in.

Also removes the two-pass stackTitles collection that was added as an
intermediate step.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Two critical safety fixes for the squash/fixup reorder feature:

1. Guard against cherry-pick abort/skip before PerformSquash: when
   --continue is called after a squash/fixup conflict, verify that HEAD
   has advanced past state.Head before calling PerformSquash. If HEAD
   hasn't moved (user ran 'git cherry-pick --abort' or '--skip'),
   PerformSquash would amend the wrong commit — now an explicit error
   directs the user to 'av reorder --abort' instead.

2. Guard against folding across the branch boundary: PerformSquash now
   accepts a branchBase parameter (populated from State.BranchBase, set
   by StackBranchCmd). If HEAD~1 equals the branch base commit, the
   cherry-picked commit is the first pick in its branch section and
   folding would amend the parent branch's tip — now an explicit error
   is returned instead of silently rewriting the wrong commit.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Comment thread internal/reorder/plan.go Outdated
// annotated with a warning so the user can see the problem in the editor.
for _, fixIdx := range unplaced {
fixPick := cmds[fixIdx].(PickCmd)
fixPick.Mode = fixups[fixIdx].mode
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this is better to be PickModePick so that it won't accidentally amend the commit prior to that branch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good call; done in f2c30b9.

Also added 3e77b87 to use --no-verify when committing fixups.

amartani and others added 2 commits April 21, 2026 11:40
When a fixup!/squash! commit has no matching target in the stack, fall
back to PickModePick instead of keeping the fixup/squash mode to avoid
accidentally squashing into an unrelated commit.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@amartani amartani requested a review from draftcode April 21, 2026 19:48
@aviator-app aviator-app Bot merged commit cfb4bc5 into aviator-co:master Apr 23, 2026
4 checks passed
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.

Feature request: Allow squashing via av reorder

3 participants