feat(rust): port stack note to native Rust#1515
Open
jd wants to merge 1 commit into
Open
Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 👀 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.
|
Base automatically changed from
devs/jd/feat/rust-stack-new/port-stack-native-rust--a8c23565
to
main
June 3, 2026 14:43
Contributor
|
@jd this pull request is now in conflict 😩 |
909582c to
d240c7a
Compare
Member
Author
Revision history
|
This was referenced Jun 3, 2026
There was a problem hiding this comment.
Pull request overview
Ports mergify stack note from the legacy Python CLI into the native Rust binary, removing the Python implementation and wiring the new subcommand through the Rust dispatch layer while keeping the rest of stack on the Python shim.
Changes:
- Add native Rust implementation of
stack note(commit resolution + set/append/remove + editor flow) and wire it into the Rust CLI dispatcher. - Remove the Python
stack notecommand implementation and its Python unit tests; keep the notes ref constant in the remaining Python consumer (stack push). - Expose
STACK_NOTES_REFinmergify-stackand adjust dependencies to support the new Rust implementation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
mergify_cli/tests/stack/test_note.py |
Removed Python unit tests for the old Python stack note implementation. |
mergify_cli/stack/push.py |
Inlines the notes ref constant as the remaining Python consumer for pushing notes. |
mergify_cli/stack/note.py |
Removes the Python implementation of stack note. |
mergify_cli/stack/cli.py |
Removes the Click registration for stack note (now routed to native Rust). |
crates/mergify-stack/src/local_commits.rs |
Makes STACK_NOTES_REF public for reuse by the new Rust command. |
crates/mergify-stack/src/commands/note.rs |
Adds the new native Rust stack note implementation plus unit tests. |
crates/mergify-stack/src/commands/mod.rs |
Exports the new note command module. |
crates/mergify-stack/Cargo.toml |
Moves tempfile to regular dependencies for runtime editor support. |
crates/mergify-cli/src/main.rs |
Adds stack note to native command routing, clap parsing, and execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The Rust binary now serves ``mergify stack note [<commit>]
[-m <msg>] [--append] [--remove]`` natively. The Python
implementation (``mergify_cli/stack/note.py``, its click
registration in ``mergify_cli/stack/cli.py``, and the unit suite
in ``mergify_cli/tests/stack/test_note.py``) is removed in the
same PR.
Second ``stack`` subcommand to land natively (after ``stack new``
in the preceding commit). The hybrid dispatcher in
``crates/mergify-cli/src/main.rs::dispatch_stack`` grows a single
``"note"`` arm; everything else still flows through the Python
shim.
``mergify stack note [<COMMIT>]`` resolves the target commit by:
1. ``None`` → ``HEAD``.
2. Argument matches ``I[0-9a-f]+`` — walk the stack
(``<merge-base trunk HEAD>..HEAD``) and match by
``Change-Id``. Reuses
``mergify_stack::trunk::get_trunk`` (added with ``stack new``)
and ``mergify_stack::local_commits::read``.
3. Otherwise — ``git rev-parse --verify <commit>^{commit}``.
Then dispatches based on the action:
- ``--remove`` — no-op when the commit has no note (prints
``No note on <sha> <subject>.`` and exits 0); otherwise
``git notes --ref=refs/notes/mergify/stack remove``.
- ``-m MSG`` (default) — ``git notes … add -f -m MSG``.
- ``-m MSG --append`` — ``git notes … append -m MSG``.
- no ``-m`` — open ``$GIT_EDITOR`` / ``$VISUAL`` / ``$EDITOR``
/ ``vi`` on a tempfile with the comment-line template, strip
comment lines, treat empty result as ``InvalidState``.
``NOTES_REF`` previously lived on the deleted
``mergify_cli/stack/note.py``. The sole remaining Python
consumer (``stack/push.py``, which pushes the notes ref alongside
the stack branches) carries its own constant now.
Exit-code mapping mirrors Python: ``InvalidState`` for empty
notes and unresolved Change-Id prefixes; ``GenericError`` for
git invocation failures.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: Iaff21093f69a3a4bec4c35102a5c113b40ff1704
d240c7a to
159cbca
Compare
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 note [<commit>] [-m <msg>] [--append] [--remove]natively. The Pythonimplementation (
mergify_cli/stack/note.py, its clickregistration in
mergify_cli/stack/cli.py, and the unit suitein
mergify_cli/tests/stack/test_note.py) is removed in thesame PR.
Second
stacksubcommand to land natively (afterstack newin the preceding commit). The hybrid dispatcher in
crates/mergify-cli/src/main.rs::dispatch_stackgrows a single"note"arm; everything else still flows through the Pythonshim.
mergify stack note [<COMMIT>]resolves the target commit by:None→HEAD.I[0-9a-f]+— walk the stack(
<merge-base trunk HEAD>..HEAD) and match byChange-Id. Reusesmergify_stack::trunk::get_trunk(added withstack new)and
mergify_stack::local_commits::read.git rev-parse --verify <commit>^{commit}.Then dispatches based on the action:
--remove— no-op when the commit has no note (printsNo note on <sha> <subject>.and exits 0); otherwisegit notes --ref=refs/notes/mergify/stack remove.-m MSG(default) —git notes … add -f -m MSG.-m MSG --append—git notes … append -m MSG.-m— open$GIT_EDITOR/$VISUAL/$EDITOR/
vion a tempfile with the comment-line template, stripcomment lines, treat empty result as
InvalidState.NOTES_REFpreviously lived on the deletedmergify_cli/stack/note.py. The sole remaining Pythonconsumer (
stack/push.py, which pushes the notes ref alongsidethe stack branches) carries its own constant now.
Exit-code mapping mirrors Python:
InvalidStatefor emptynotes and unresolved Change-Id prefixes;
GenericErrorforgit invocation failures.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com