feat(rust): port stack squash to native Rust#1521
Merged
mergify[bot] merged 1 commit intoJun 8, 2026
Merged
Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced Jun 3, 2026
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 👀 Review RequirementsWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 ReviewsWonderful, this rule succeeded.
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
This was referenced Jun 3, 2026
9342e5c to
f86d325
Compare
Member
Author
Revision history
|
3e2b895 to
ec2360e
Compare
f86d325 to
beed698
Compare
JulianMaurin
previously approved these changes
Jun 4, 2026
beed698 to
b5699bc
Compare
ec2360e to
e4aabd1
Compare
3116a40 to
ccfaf02
Compare
ccfaf02 to
bdf0e4a
Compare
JulianMaurin
previously approved these changes
Jun 5, 2026
Base automatically changed from
devs/jd/feat/rust-stack-new/port-stack-reorder-stack-move-native-rust--8b603412
to
main
June 8, 2026 09:49
Contributor
|
@jd this pull request is now in conflict 😩 |
The Rust binary now serves ``mergify stack squash <SRC>... into <TARGET> [-m <msg>] [--dry-run]`` natively. With this slice, the entire ``stack`` rebase family is native: ``edit``, ``drop``, ``fixup``, ``reword``, ``reorder``, ``move``, ``squash``. Final cleanup: ``mergify_cli/stack/squash.py``, ``mergify_cli/stack/reorder.py`` (the helpers ``squash.py`` was still using), and their tests (``test_squash.py``, ``test_squash_cli.py``) are removed. ``mergify_cli/stack/cli.py`` loses its ``squash`` click registration and its ``_parse_squash_tokens`` helper. The rebase-todo machinery grows one new variant — ``Action::Squash`` — that combines what ``Reorder`` and ``Fixup`` did separately plus an optional ``ExecAfter``: - ``ordered_shas`` — the full new pick order (target's neighbours rearranged so all sources sit directly after it). - ``fixup_shas`` — the subset whose verb flips from ``pick`` to ``fixup``. - ``exec_after_sha`` + ``exec_command`` — when ``-m`` is given, an ``exec git commit --amend -F <file>`` is injected right after the last fixed-up source. The amend runs while HEAD still points at the combined target commit so ``prepare-commit-msg`` re-attaches the Change-Id. ``mergify stack squash``: 1. Resolves the trunk and walks the stack. 2. Parses ``SRC... into TARGET`` — the ``into`` keyword splits the positional list. Mirrors the Python parser: exactly one ``into``, at least one source before, exactly one target after. 3. Validates: target is not among the sources; no source SHA appears twice. 4. Builds the new order: keep non-source commits in their original positions, insert all sources directly after target in the order they were listed. 5. ``--dry-run`` short-circuits with the plan; otherwise spawns ``git rebase -i <base>`` with the squash sequence editor. 6. With ``-m``: writes the message to a leaked tempfile and passes it through ``--sha``/``--command`` on the ``rebase-todo-rewrite`` self-invocation. End-to-end coverage in ``crates/mergify-cli/tests/stack_squash.rs`` (6 cases): single source into target keeps target's message, custom ``-m`` replaces subject + body, dry-run is a no-op, source-equals- target errors, missing ``into`` errors, multi-source folds all into target. The pure transformer adds 3 new ``rebase_todo`` unit tests (happy path, exec-after injection, count mismatch). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Change-Id: I380f216ca57ebf78c8fb6c62e3a5af48a9dfdd55
bdf0e4a to
b0223f3
Compare
remyduthu
approved these changes
Jun 8, 2026
JulianMaurin
approved these changes
Jun 8, 2026
Contributor
Merge Queue Status
This pull request spent 1 minute 19 seconds in the queue, including 8 seconds running CI. Required conditions to merge
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Rust binary now serves
mergify stack squash <SRC>... into <TARGET> [-m <msg>] [--dry-run]natively. With this slice, theentire
stackrebase family is native:edit,drop,fixup,reword,reorder,move,squash.Final cleanup:
mergify_cli/stack/squash.py,mergify_cli/stack/reorder.py(the helperssquash.pywasstill using), and their tests (
test_squash.py,test_squash_cli.py) are removed.mergify_cli/stack/cli.pyloses its
squashclick registration and its_parse_squash_tokenshelper.The rebase-todo machinery grows one new variant —
Action::Squash— that combines whatReorderandFixupdid separately plus an optionalExecAfter:ordered_shas— the full new pick order (target's neighboursrearranged so all sources sit directly after it).
fixup_shas— the subset whose verb flips frompicktofixup.exec_after_sha+exec_command— when-mis given,an
exec git commit --amend -F <file>is injected rightafter the last fixed-up source. The amend runs while HEAD
still points at the combined target commit so
prepare-commit-msgre-attaches the Change-Id.mergify stack squash:SRC... into TARGET— theintokeyword splitsthe positional list. Mirrors the Python parser:
exactly one
into, at least one source before, exactlyone target after.
appears twice.
original positions, insert all sources directly after
target in the order they were listed.
--dry-runshort-circuits with the plan; otherwise spawnsgit rebase -i <base>with the squash sequence editor.-m: writes the message to a leaked tempfile andpasses it through
--sha/--commandon therebase-todo-rewriteself-invocation.End-to-end coverage in
crates/mergify-cli/tests/stack_squash.rs(6 cases): singlesource into target keeps target's message, custom
-mreplaces subject + body, dry-run is a no-op, source-equals-
target errors, missing
intoerrors, multi-source folds allinto target. The pure transformer adds 3 new
rebase_todounit tests (happy path, exec-after injection, count mismatch).
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com