feat(rust): port stack reorder + stack move to native Rust#1520
Draft
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 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
42b64a3 to
9d01b71
Compare
0b09239 to
3e2b895
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 reorder <COMMIT>... [--dry-run]andmergify 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, andmergify_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 onmergify_stack::rebase_todo. The transformer rebuilds thetodo with picks in the requested order and appends every
non-pick line (comments, blanks,
execannotations) at theend, mirroring Python's
run_action_rebasebucketing.mergify stack reorder: the<COMMIT>...arguments listevery 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 orderand don't spawn arebase.
mergify stack move: a thin wrapper that computes the neworder from
<COMMIT> <POSITION> [<TARGET>]and then delegatesto the same
Action::Reorderpath.POSITIONis one offirst,last,before,after;beforeandafterrequire a<TARGET>,firstandlastrejectone.
The Python
stack_reorder/stack_movefunctions are gone,but
mergify_cli/stack/reorder.pyitself is kept as aheader file: it still hosts the
get_stack_commits,match_commit,run_scripted_rebase,run_action_rebaseanddisplay_*helpers that theremaining Python
stack_squash(the next slice) still dependson. When
stack squashfollows, the whole file goes.Also fixes a parallel-test flake in
crates/mergify-cli/tests/stack_*.rs: each integration testfile now spawns
gitthrough a localisolated_git()helper that sets
GIT_CONFIG_GLOBAL=/dev/nullandGIT_CONFIG_NOSYSTEM=1, matching the lib-test fixturebehavior. Symptom was sporadic
gitfailures when many testbinaries ran their per-test fixtures concurrently.
End-to-end coverage in
crates/mergify-cli/tests/stack_reorder.rs(7 cases): reorderto explicit sequence, already-in-order is a no-op, count
mismatch errors, move to
first, movebeforetarget, movebeforewithout target errors, movefirstwith targeterrors. The pure transformer adds 3 new
rebase_todounittests (happy path, count mismatch, unknown SHA).
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
Depends-On: #1519