You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(rust): port stack squash to native Rust (#1521)
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>
0 commit comments