feat(rust): port stack reword to native Rust#1519
Draft
jd wants to merge 1 commit into
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. 🔴 ⛓️ Depends-On RequirementsWaiting for
This rule is failing.Requirement based on the presence of
🔴 👀 Review RequirementsWaiting for
This rule is failing.
🔴 🔎 ReviewsWaiting for
This rule is failing.
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
This was referenced Jun 3, 2026
The Rust binary now serves ``mergify stack reword <COMMIT>
[-m <msg>] [--dry-run]`` natively. The Python implementation
(``mergify_cli/stack/reword.py``, its click registration, and
``mergify_cli/tests/stack/test_reword.py``) is removed in the
same PR.
Two new ``rebase_todo`` actions back the two flavors:
- ``Action::Reword { sha }`` rewrites the target ``pick`` line as
``reword``. Git pauses on the commit and runs
``git commit --amend``, opening ``$GIT_EDITOR``. Used when no
``-m`` argument is given.
- ``Action::ExecAfter { sha, command }`` injects an ``exec
<command>`` line directly after the target ``pick`` line. Used
with ``-m``: the message is written to a tempfile and the
exec runs ``git commit --amend -F <file>`` while HEAD still
points at the target commit, so any ``prepare-commit-msg``
hook re-attaches the Change-Id. Tempfile is intentionally
leaked so ``git rebase --continue`` after a conflict can still
find it. The ``ExecAfter`` shape lands here because it is also
the squash-with-custom-message machinery, so the next slice
reuses it for free.
``mergify stack reword <COMMIT> [-m <msg>] [--dry-run]``:
1. Resolves the trunk and walks the stack (shared with the
other rebase-family commands).
2. Matches the ``<COMMIT>`` argument by SHA-prefix or Change-Id
prefix.
3. ``--dry-run`` short-circuits with a ``Reword plan:`` line
showing ``reword`` (no ``-m``) or ``amend`` (``-m`` given) so
the dry-run text matches Python.
4. Otherwise spawns ``git rebase -i <base>`` with
``GIT_SEQUENCE_EDITOR`` pointing at the binary's
``_internal rebase-todo-rewrite`` subcommand.
End-to-end coverage in
``crates/mergify-cli/tests/stack_reword.rs`` (3 cases): ``-m``
replaces subject + body, ``--dry-run`` is a no-op, unknown
prefix exits non-zero. The pure transformer is covered by 4
new ``rebase_todo`` unit tests (reword happy path / no match;
exec-after happy path / no match).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: I39f31d0f8b31b890a3a390e928f7342ca04cd7b7
42b64a3 to
9d01b71
Compare
Member
Author
Revision history
|
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 reword <COMMIT> [-m <msg>] [--dry-run]natively. The Python implementation(
mergify_cli/stack/reword.py, its click registration, andmergify_cli/tests/stack/test_reword.py) is removed in thesame PR.
Two new
rebase_todoactions back the two flavors:Action::Reword { sha }rewrites the targetpickline asreword. Git pauses on the commit and runsgit commit --amend, opening$GIT_EDITOR. Used when no-margument is given.Action::ExecAfter { sha, command }injects anexec <command>line directly after the targetpickline. Usedwith
-m: the message is written to a tempfile and theexec runs
git commit --amend -F <file>while HEAD stillpoints at the target commit, so any
prepare-commit-msghook re-attaches the Change-Id. Tempfile is intentionally
leaked so
git rebase --continueafter a conflict can stillfind it. The
ExecAftershape lands here because it is alsothe squash-with-custom-message machinery, so the next slice
reuses it for free.
mergify stack reword <COMMIT> [-m <msg>] [--dry-run]:other rebase-family commands).
<COMMIT>argument by SHA-prefix or Change-Idprefix.
--dry-runshort-circuits with aReword plan:lineshowing
reword(no-m) oramend(-mgiven) sothe dry-run text matches Python.
git rebase -i <base>withGIT_SEQUENCE_EDITORpointing at the binary's_internal rebase-todo-rewritesubcommand.End-to-end coverage in
crates/mergify-cli/tests/stack_reword.rs(3 cases):-mreplaces subject + body,
--dry-runis a no-op, unknownprefix exits non-zero. The pure transformer is covered by 4
new
rebase_todounit tests (reword happy path / no match;exec-after happy path / no match).
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
Depends-On: #1518