Skip to content

feat(rust): port stack note to native Rust#1515

Open
jd wants to merge 1 commit into
mainfrom
devs/jd/feat/rust-stack-new/port-stack-note-native-rust--aff21093
Open

feat(rust): port stack note to native Rust#1515
jd wants to merge 1 commit into
mainfrom
devs/jd/feat/rust-stack-new/port-stack-note-native-rust--aff21093

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Jun 3, 2026

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. NoneHEAD.
  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 --appendgit 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

@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 13:50 Failure
@jd jd temporarily deployed to func-tests-live June 3, 2026 13:50 — 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.

🔴 👀 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,})

@mergify mergify Bot requested a review from a team June 3, 2026 14:06
Base automatically changed from devs/jd/feat/rust-stack-new/port-stack-native-rust--a8c23565 to main June 3, 2026 14:43
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jun 3, 2026

@jd this pull request is now in conflict 😩

@mergify mergify Bot added the conflict label Jun 3, 2026
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-note-native-rust--aff21093 branch from 909582c to d240c7a Compare June 3, 2026 15:35
@jd
Copy link
Copy Markdown
Member Author

jd commented Jun 3, 2026

Revision history

# Type Changes Reason Date
1 initial 909582c 2026-06-03 15:35 UTC
2 rebase 909582c → d240c7a (rebase only) 2026-06-03 15:35 UTC
3 content d240c7a → 159cbca (raw) address Copilot review on #1515: treat empty GIT_EDITOR as unset, fix Windows tempfile-with-spaces quoting in invoke_editor, add 3 regression tests covering Action::FromEditor (strip comments, reject… 2026-06-03 21:01 UTC

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 note command implementation and its Python unit tests; keep the notes ref constant in the remaining Python consumer (stack push).
  • Expose STACK_NOTES_REF in mergify-stack and 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.

Comment thread crates/mergify-stack/src/commands/note.rs Outdated
Comment thread crates/mergify-stack/src/commands/note.rs
Comment thread crates/mergify-stack/src/commands/note.rs
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
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-note-native-rust--aff21093 branch from d240c7a to 159cbca Compare June 3, 2026 21:01
@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.

2 participants