feat(rust): port stack drop to native Rust#1517
Open
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 drop <COMMIT>...
[--dry-run]`` natively. The Python implementation
(``mergify_cli/stack/drop.py``, its click registration, and
``mergify_cli/tests/stack/test_drop.py``) is removed in the same
PR.
Fourth ``stack`` subcommand to land natively. Builds on the
rebase-todo machinery introduced with ``stack edit``: this slice
adds one ``Action::Drop { shas }`` variant to
``mergify_stack::rebase_todo`` (which deletes the targeted
``pick`` lines from the todo) and one new arm in the
``_internal rebase-todo-rewrite`` subcommand. No new bridge
surface — the existing
``_internal rebase-todo-rewrite --action drop --shas <SHA,…>``
fits the pre-port pattern.
``mergify stack drop <COMMIT>... [--dry-run]``:
1. Resolves the trunk and walks the stack (shared with
``stack edit``).
2. Matches each ``<COMMIT>`` argument against the walker by SHA
prefix or Change-Id prefix. Duplicate prefixes (two args
resolving to the same commit) are rejected with
``InvalidState``.
3. ``--dry-run`` short-circuits with a ``Drop plan:`` table and
exits 0 without touching git.
4. Otherwise spawns ``git rebase -i <base>`` with
``GIT_SEQUENCE_EDITOR`` pointing at the binary's
``_internal rebase-todo-rewrite --action drop --shas
<comma-separated>``; the todo rewriter removes the targeted
``pick`` lines and git replays the rebase.
The rewriter requires every targeted SHA to match exactly one
``pick`` line — a partial match aborts the rebase with
``InvalidState`` listing the missing SHAs, so the user never
ends up with a half-applied drop.
End-to-end coverage in
``crates/mergify-cli/tests/stack_drop.rs`` (6 cases mirroring
the deleted Python ``test_drop.py``): drop middle, drop
multiple, drop by Change-Id, ``--dry-run`` is a no-op, unknown
prefix exits non-zero, duplicate prefix rejected. The pure
transformer is covered by 5 new ``rebase_todo`` unit tests
(happy path, multi-target, no-match, partial match,
empty-target).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: I22a924187bf504fd13515f0c8e5512e57b6dff40
0fb3418 to
8049535
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 drop <COMMIT>... [--dry-run]natively. The Python implementation(
mergify_cli/stack/drop.py, its click registration, andmergify_cli/tests/stack/test_drop.py) is removed in the samePR.
Fourth
stacksubcommand to land natively. Builds on therebase-todo machinery introduced with
stack edit: this sliceadds one
Action::Drop { shas }variant tomergify_stack::rebase_todo(which deletes the targetedpicklines from the todo) and one new arm in the_internal rebase-todo-rewritesubcommand. No new bridgesurface — the existing
_internal rebase-todo-rewrite --action drop --shas <SHA,…>fits the pre-port pattern.
mergify stack drop <COMMIT>... [--dry-run]:stack edit).<COMMIT>argument against the walker by SHAprefix or Change-Id prefix. Duplicate prefixes (two args
resolving to the same commit) are rejected with
InvalidState.--dry-runshort-circuits with aDrop plan:table andexits 0 without touching git.
git rebase -i <base>withGIT_SEQUENCE_EDITORpointing at the binary's_internal rebase-todo-rewrite --action drop --shas <comma-separated>; the todo rewriter removes the targetedpicklines and git replays the rebase.The rewriter requires every targeted SHA to match exactly one
pickline — a partial match aborts the rebase withInvalidStatelisting the missing SHAs, so the user neverends up with a half-applied drop.
End-to-end coverage in
crates/mergify-cli/tests/stack_drop.rs(6 cases mirroringthe deleted Python
test_drop.py): drop middle, dropmultiple, drop by Change-Id,
--dry-runis a no-op, unknownprefix exits non-zero, duplicate prefix rejected. The pure
transformer is covered by 5 new
rebase_todounit tests(happy path, multi-target, no-match, partial match,
empty-target).
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
Depends-On: #1516