Skip to content

feat(rust): port stack squash to native Rust#1521

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/jd/feat/rust-stack-new/port-stack-squash-native-rust--380f216c
Jun 8, 2026
Merged

feat(rust): port stack squash to native Rust#1521
mergify[bot] merged 1 commit into
mainfrom
devs/jd/feat/rust-stack-new/port-stack-squash-native-rust--380f216c

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Jun 3, 2026

The Rust binary now serves mergify stack squash <SRC>... into <TARGET> [-m <msg>] [--dry-run] natively. With this slice, the
entire stack rebase family is native: edit, drop,
fixup, reword, reorder, move, squash.

Final cleanup: mergify_cli/stack/squash.py,
mergify_cli/stack/reorder.py (the helpers squash.py was
still using), and their tests (test_squash.py,
test_squash_cli.py) are removed. mergify_cli/stack/cli.py
loses its squash click registration and its
_parse_squash_tokens helper.

The rebase-todo machinery grows one new variant —
Action::Squash — that combines what Reorder and
Fixup did separately plus an optional ExecAfter:

  • ordered_shas — the full new pick order (target's neighbours
    rearranged so all sources sit directly after it).
  • fixup_shas — the subset whose verb flips from pick to
    fixup.
  • exec_after_sha + exec_command — when -m is given,
    an exec git commit --amend -F <file> is injected right
    after the last fixed-up source. The amend runs while HEAD
    still points at the combined target commit so
    prepare-commit-msg re-attaches the Change-Id.

mergify stack squash:

  1. Resolves the trunk and walks the stack.
  2. Parses SRC... into TARGET — the into keyword splits
    the positional list. Mirrors the Python parser:
    exactly one into, at least one source before, exactly
    one target after.
  3. Validates: target is not among the sources; no source SHA
    appears twice.
  4. Builds the new order: keep non-source commits in their
    original positions, insert all sources directly after
    target in the order they were listed.
  5. --dry-run short-circuits with the plan; otherwise spawns
    git rebase -i <base> with the squash sequence editor.
  6. With -m: writes the message to a leaked tempfile and
    passes it through --sha/--command on the
    rebase-todo-rewrite self-invocation.

End-to-end coverage in
crates/mergify-cli/tests/stack_squash.rs (6 cases): single
source into target keeps target's message, custom -m
replaces subject + body, dry-run is a no-op, source-equals-
target errors, missing into errors, multi-source folds all
into target. The pure transformer adds 3 new rebase_todo
unit tests (happy path, exec-after injection, count mismatch).

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

@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 squash to native Rust #1521 👈
2 feat(rust): port stack checkout to native Rust #1522
3 feat(rust): port stack sync to native Rust #1523
4 feat(rust): port stack list + stack open to native Rust #1524
5 feat(rust): port stack hooks + stack setup to native Rust #1527
6 feat(rust): port stack push end-to-end + delete Python push.py #1553
7 chore: delete Python tree + simplify wheel/CI for pure-Rust binary #1554
8 refactor(stack): extract shared git helpers into crate::git #1555
9 ci(workflows): align smoke-test-binary on python 3.14 #1557

@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.

🟢 🤖 Continuous Integration

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

🟢 👀 Review Requirements

Wonderful, this rule succeeded.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 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)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

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

@mergify mergify Bot requested a review from a team June 3, 2026 19:27
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-squash-native-rust--380f216c branch from 9342e5c to f86d325 Compare June 3, 2026 21:01
@jd jd temporarily deployed to func-tests-live June 3, 2026 21:01 — with GitHub Actions Inactive
@jd
Copy link
Copy Markdown
Member Author

jd commented Jun 3, 2026

Revision history

# Type Changes Reason Date
1 initial 9342e5c 2026-06-03 21:01 UTC
2 rebase 9342e5c → f86d325 (rebase only) 2026-06-03 21:01 UTC
3 rebase f86d325 → beed698 (rebase only) 2026-06-04 08:51 UTC
4 rebase beed698 → b5699bc (rebase only) 2026-06-04 13:29 UTC
5 rebase b5699bc → 96311dd (rebase only) 2026-06-05 07:01 UTC
6 rebase 96311dd → 3116a40 (rebase only) 2026-06-05 08:13 UTC
7 rebase 3116a40 → ccfaf02 (rebase only) 2026-06-05 09:38 UTC
8 rebase ccfaf02 → bdf0e4a (rebase only) 2026-06-05 12:37 UTC
9 rebase bdf0e4a → b0223f3 (rebase only) 2026-06-08 11:31 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 3, 2026 21:01 Failure
@jd jd marked this pull request as ready for review June 4, 2026 08:46
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-reorder-stack-move-native-rust--8b603412 branch from 3e2b895 to ec2360e Compare June 4, 2026 08:51
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-squash-native-rust--380f216c branch from f86d325 to beed698 Compare June 4, 2026 08:51
@jd jd temporarily deployed to func-tests-live June 4, 2026 08:51 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live June 4, 2026 08:51 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 4, 2026 08:52 Failure
JulianMaurin
JulianMaurin previously approved these changes Jun 4, 2026
@mergify mergify Bot requested a review from a team June 4, 2026 12:18
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-squash-native-rust--380f216c branch from beed698 to b5699bc Compare June 4, 2026 13:29
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-reorder-stack-move-native-rust--8b603412 branch from ec2360e to e4aabd1 Compare June 4, 2026 13:29
@jd jd temporarily deployed to func-tests-live June 4, 2026 13:29 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live June 5, 2026 08:13 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live June 5, 2026 08:13 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 5, 2026 08:13 Failure
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-squash-native-rust--380f216c branch from 3116a40 to ccfaf02 Compare June 5, 2026 09:38
@jd jd temporarily deployed to func-tests-live June 5, 2026 09:38 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 5, 2026 09:38 Failure
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-squash-native-rust--380f216c branch from ccfaf02 to bdf0e4a Compare June 5, 2026 12:37
@jd jd temporarily deployed to func-tests-live June 5, 2026 12:37 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 5, 2026 12:37 Failure
JulianMaurin
JulianMaurin previously approved these changes Jun 5, 2026
@mergify mergify Bot requested a review from a team June 5, 2026 12:46
Base automatically changed from devs/jd/feat/rust-stack-new/port-stack-reorder-stack-move-native-rust--8b603412 to main June 8, 2026 09:49
@mergify mergify Bot dismissed JulianMaurin’s stale review June 8, 2026 09:49

The base branch was changed.

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jun 8, 2026

@jd this pull request is now in conflict 😩

@mergify mergify Bot added the conflict label Jun 8, 2026
The Rust binary now serves ``mergify stack squash <SRC>... into
<TARGET> [-m <msg>] [--dry-run]`` natively. With this slice, the
entire ``stack`` rebase family is native: ``edit``, ``drop``,
``fixup``, ``reword``, ``reorder``, ``move``, ``squash``.

Final cleanup: ``mergify_cli/stack/squash.py``,
``mergify_cli/stack/reorder.py`` (the helpers ``squash.py`` was
still using), and their tests (``test_squash.py``,
``test_squash_cli.py``) are removed. ``mergify_cli/stack/cli.py``
loses its ``squash`` click registration and its
``_parse_squash_tokens`` helper.

The rebase-todo machinery grows one new variant —
``Action::Squash`` — that combines what ``Reorder`` and
``Fixup`` did separately plus an optional ``ExecAfter``:

- ``ordered_shas`` — the full new pick order (target's neighbours
  rearranged so all sources sit directly after it).
- ``fixup_shas`` — the subset whose verb flips from ``pick`` to
  ``fixup``.
- ``exec_after_sha`` + ``exec_command`` — when ``-m`` is given,
  an ``exec git commit --amend -F <file>`` is injected right
  after the last fixed-up source. The amend runs while HEAD
  still points at the combined target commit so
  ``prepare-commit-msg`` re-attaches the Change-Id.

``mergify stack squash``:

1. Resolves the trunk and walks the stack.
2. Parses ``SRC... into TARGET`` — the ``into`` keyword splits
   the positional list. Mirrors the Python parser:
   exactly one ``into``, at least one source before, exactly
   one target after.
3. Validates: target is not among the sources; no source SHA
   appears twice.
4. Builds the new order: keep non-source commits in their
   original positions, insert all sources directly after
   target in the order they were listed.
5. ``--dry-run`` short-circuits with the plan; otherwise spawns
   ``git rebase -i <base>`` with the squash sequence editor.
6. With ``-m``: writes the message to a leaked tempfile and
   passes it through ``--sha``/``--command`` on the
   ``rebase-todo-rewrite`` self-invocation.

End-to-end coverage in
``crates/mergify-cli/tests/stack_squash.rs`` (6 cases): single
source into target keeps target's message, custom ``-m``
replaces subject + body, dry-run is a no-op, source-equals-
target errors, missing ``into`` errors, multi-source folds all
into target. The pure transformer adds 3 new ``rebase_todo``
unit tests (happy path, exec-after injection, count mismatch).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: I380f216ca57ebf78c8fb6c62e3a5af48a9dfdd55
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-squash-native-rust--380f216c branch from bdf0e4a to b0223f3 Compare June 8, 2026 11:31
@jd jd temporarily deployed to func-tests-live June 8, 2026 11:31 — with GitHub Actions Inactive
@mergify mergify Bot deployed to Mergify Merge Protections June 8, 2026 11:31 Active
@mergify mergify Bot removed the conflict label Jun 8, 2026
@mergify mergify Bot requested a review from a team June 8, 2026 12:24
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jun 8, 2026

Merge Queue Status

  • Entered queue2026-06-08 14:48 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-06-08 14:49 UTC · at b0223f39130ed27b1db2ab26d882194f9e448c45 · squash

This pull request spent 1 minute 19 seconds in the queue, including 8 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Jun 8, 2026
@mergify mergify Bot merged commit db54760 into main Jun 8, 2026
19 checks passed
@mergify mergify Bot deleted the devs/jd/feat/rust-stack-new/port-stack-squash-native-rust--380f216c branch June 8, 2026 14:49
@mergify mergify Bot removed the queued label Jun 8, 2026
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.

3 participants