Skip to content

feat(rust): port stack reorder + stack move to native Rust#1520

Draft
jd wants to merge 1 commit into
devs/jd/feat/rust-stack-new/port-stack-reword-native-rust--39f31d0ffrom
devs/jd/feat/rust-stack-new/port-stack-reorder-stack-move-native-rust--8b603412
Draft

feat(rust): port stack reorder + stack move to native Rust#1520
jd wants to merge 1 commit into
devs/jd/feat/rust-stack-new/port-stack-reword-native-rust--39f31d0ffrom
devs/jd/feat/rust-stack-new/port-stack-reorder-stack-move-native-rust--8b603412

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Jun 3, 2026

The Rust binary now serves mergify stack reorder <COMMIT>... [--dry-run] and mergify stack move <COMMIT> <POSITION> [<TARGET>] [--dry-run] natively. The Python implementations
(mergify_cli/stack/reorder.py::stack_reorder,
mergify_cli/stack/move.py, their click registrations, and
mergify_cli/tests/stack/test_{reorder,move}.py) are removed.

Both commands reduce to the same rebase-todo transformation —
they only differ in how they compute the desired pick order —
so this slice ships both behind a single new
Action::Reorder { ordered_shas } variant on
mergify_stack::rebase_todo. The transformer rebuilds the
todo with picks in the requested order and appends every
non-pick line (comments, blanks, exec annotations) at the
end, mirroring Python's run_action_rebase bucketing.

mergify stack reorder: the <COMMIT>... arguments list
every stack commit in the desired new order. Validation rejects
duplicate prefixes, prefixes that don't resolve, and length
mismatches. When the requested order already matches the
current order, we short-circuit with
Stack is already in the requested order and don't spawn a
rebase.

mergify stack move: a thin wrapper that computes the new
order from <COMMIT> <POSITION> [<TARGET>] and then delegates
to the same Action::Reorder path. POSITION is one of
first, last, before, after; before and
after require a <TARGET>, first and last reject
one.

The Python stack_reorder/stack_move functions are gone,
but mergify_cli/stack/reorder.py itself is kept as a
header file: it still hosts the get_stack_commits,
match_commit, run_scripted_rebase,
run_action_rebase and display_* helpers that the
remaining Python stack_squash (the next slice) still depends
on. When stack squash follows, the whole file goes.

Also fixes a parallel-test flake in
crates/mergify-cli/tests/stack_*.rs: each integration test
file now spawns git through a local isolated_git()
helper that sets GIT_CONFIG_GLOBAL=/dev/null and
GIT_CONFIG_NOSYSTEM=1, matching the lib-test fixture
behavior. Symptom was sporadic git failures when many test
binaries ran their per-test fixtures concurrently.

End-to-end coverage in
crates/mergify-cli/tests/stack_reorder.rs (7 cases): reorder
to explicit sequence, already-in-order is a no-op, count
mismatch errors, move to first, move before target, move
before without target errors, move first with target
errors. The pure transformer adds 3 new rebase_todo unit
tests (happy path, count mismatch, unknown SHA).

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

Depends-On: #1519

@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
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 reorder <COMMIT>...
[--dry-run]`` and ``mergify stack move <COMMIT> <POSITION>
[<TARGET>] [--dry-run]`` natively. The Python implementations
(``mergify_cli/stack/reorder.py::stack_reorder``,
``mergify_cli/stack/move.py``, their click registrations, and
``mergify_cli/tests/stack/test_{reorder,move}.py``) are removed.

Both commands reduce to the same rebase-todo transformation —
they only differ in how they compute the desired pick order —
so this slice ships both behind a single new
``Action::Reorder { ordered_shas }`` variant on
``mergify_stack::rebase_todo``. The transformer rebuilds the
todo with picks in the requested order and appends every
non-pick line (comments, blanks, ``exec`` annotations) at the
end, mirroring Python's ``run_action_rebase`` bucketing.

``mergify stack reorder``: the ``<COMMIT>...`` arguments list
every stack commit in the desired new order. Validation rejects
duplicate prefixes, prefixes that don't resolve, and length
mismatches. When the requested order already matches the
current order, we short-circuit with
``Stack is already in the requested order`` and don't spawn a
rebase.

``mergify stack move``: a thin wrapper that computes the new
order from ``<COMMIT> <POSITION> [<TARGET>]`` and then delegates
to the same ``Action::Reorder`` path. ``POSITION`` is one of
``first``, ``last``, ``before``, ``after``; ``before`` and
``after`` require a ``<TARGET>``, ``first`` and ``last`` reject
one.

The Python ``stack_reorder``/``stack_move`` functions are gone,
but ``mergify_cli/stack/reorder.py`` itself is kept as a
header file: it still hosts the ``get_stack_commits``,
``match_commit``, ``run_scripted_rebase``,
``run_action_rebase`` and ``display_*`` helpers that the
remaining Python ``stack_squash`` (the next slice) still depends
on. When ``stack squash`` follows, the whole file goes.

Also fixes a parallel-test flake in
``crates/mergify-cli/tests/stack_*.rs``: each integration test
file now spawns ``git`` through a local ``isolated_git()``
helper that sets ``GIT_CONFIG_GLOBAL=/dev/null`` and
``GIT_CONFIG_NOSYSTEM=1``, matching the lib-test fixture
behavior. Symptom was sporadic ``git`` failures when many test
binaries ran their per-test fixtures concurrently.

End-to-end coverage in
``crates/mergify-cli/tests/stack_reorder.rs`` (7 cases): reorder
to explicit sequence, already-in-order is a no-op, count
mismatch errors, move to ``first``, move ``before`` target, move
``before`` without target errors, move ``first`` with target
errors. The pure transformer adds 3 new ``rebase_todo`` unit
tests (happy path, count mismatch, unknown SHA).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: I8b603412b742c1a863f5c807b05c954635dd0e94
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-reword-native-rust--39f31d0f branch from 42b64a3 to 9d01b71 Compare June 3, 2026 21:01
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-reorder-stack-move-native-rust--8b603412 branch from 0b09239 to 3e2b895 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 0b09239 2026-06-03 21:01 UTC
2 rebase 0b09239 → 3e2b895 (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
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