Commit 3e20ad4
feat(rust): port stack note to native Rust (#1515)
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>1 parent 029c388 commit 3e20ad4
10 files changed
Lines changed: 790 additions & 484 deletions
File tree
- crates
- mergify-cli/src
- mergify-stack
- src
- commands
- mergify_cli
- stack
- tests/stack
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
| |||
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
218 | 238 | | |
219 | 239 | | |
220 | 240 | | |
| |||
481 | 501 | | |
482 | 502 | | |
483 | 503 | | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
493 | 523 | | |
494 | | - | |
495 | 524 | | |
496 | 525 | | |
497 | 526 | | |
| |||
1169 | 1198 | | |
1170 | 1199 | | |
1171 | 1200 | | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1172 | 1243 | | |
1173 | 1244 | | |
1174 | 1245 | | |
| |||
1361 | 1432 | | |
1362 | 1433 | | |
1363 | 1434 | | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
1364 | 1479 | | |
1365 | 1480 | | |
1366 | 1481 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
0 commit comments