Skip to content

feat(rust): port stack drop to native Rust#1517

Open
jd wants to merge 1 commit into
devs/jd/feat/rust-stack-new/port-stack-edit-add-rebase-todo-machinery--d6b5db4efrom
devs/jd/feat/rust-stack-new/port-stack-drop-native-rust--22a92418
Open

feat(rust): port stack drop to native Rust#1517
jd wants to merge 1 commit into
devs/jd/feat/rust-stack-new/port-stack-edit-add-rebase-todo-machinery--d6b5db4efrom
devs/jd/feat/rust-stack-new/port-stack-drop-native-rust--22a92418

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented 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

Depends-On: #1516

@jd
Copy link
Copy Markdown
Member Author

jd commented Jun 3, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(rust): port stack note to native Rust #1515
2 feat(rust): port stack edit + add rebase-todo machinery #1516
3 feat(rust): port stack drop to native Rust #1517 👈
4 feat(rust): port stack fixup to native Rust #1518
5 feat(rust): port stack reword to native Rust #1519
6 feat(rust): port stack reorder + stack move to native Rust #1520
7 feat(rust): port stack squash to native Rust #1521
8 feat(rust): port stack checkout to native Rust #1522
9 feat(rust): port stack sync to native Rust #1523
10 feat(rust): port stack list + stack open to native Rust #1524

@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 3, 2026 17:44 Failure
@jd jd temporarily deployed to func-tests-live June 3, 2026 17:44 — with GitHub Actions Inactive
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jun 3, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 ⛓️ Depends-On Requirements

Waiting for

This rule is failing.

Requirement based on the presence of Depends-On in the body of the pull request

🔴 👀 Review Requirements

Waiting for

  • #approved-reviews-by>=2
This rule is failing.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🔴 🔎 Reviews

Waiting for

  • #review-requested = 0
This rule is failing.
  • #review-requested = 0
  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

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
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-drop-native-rust--22a92418 branch from 0fb3418 to 8049535 Compare June 3, 2026 21:01
@jd
Copy link
Copy Markdown
Member Author

jd commented Jun 3, 2026

Revision history

# Type Changes Reason Date
1 initial 0fb3418 2026-06-03 21:01 UTC
2 rebase 0fb3418 → 8049535 (rebase only) 2026-06-03 21:01 UTC

@jd jd temporarily deployed to func-tests-live June 3, 2026 21:01 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 3, 2026 21:01 Failure
@mergify mergify Bot requested a review from a team June 3, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant