feat(rust): port stack hooks + stack setup to native Rust#1527
Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced Jun 4, 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.
|
d27f347 to
56cb890
Compare
f80abfe to
3b2e1b1
Compare
Member
Author
Revision history
|
56cb890 to
e5c33cc
Compare
3b2e1b1 to
65aaa32
Compare
e5c33cc to
d2bd9e8
Compare
65aaa32 to
b9ab524
Compare
291e013 to
77e1b99
Compare
fd18ff2 to
7106eca
Compare
77e1b99 to
897e0bf
Compare
897e0bf to
cd3f76c
Compare
cb73efd to
b7ee9f5
Compare
b7ee9f5 to
5a7352d
Compare
cd3f76c to
8ee0f09
Compare
The Rust binary now serves both ``mergify stack hooks`` (status
+ ``--setup``) and ``mergify stack setup`` (alias for
``hooks --setup``, plus ``--check``). The Python implementation
(``mergify_cli/stack/setup.py``, the click registrations, the
``test_setup.py`` suite, and the hook resource tree under
``mergify_cli/stack/hooks/``) is removed. The hook scripts and
wrappers are renamed to ``crates/mergify-stack/hooks/{scripts,
wrappers}/`` and embedded into the binary via ``include_str!``.
``mergify_stack::commands::setup``:
- Mirrors Python's on-disk layout exactly so a checkout
upgraded from a Python install is recognised without
re-installation: ``.git/hooks/<hook>`` is the thin wrapper
(user-editable below the marker comment),
``.git/hooks/mergify-hooks/<hook>.sh`` is the managed script
(always upgradable).
- ``WrapperStatus`` detection mirrors ``_get_wrapper_status``:
``mergify-hooks`` + ``<hook>.sh`` substring pair = ours;
legacy heuristics (``Change-Id: I${random}`` on
``commit-msg``, ``is_amend_with_m_flag`` on
``prepare-commit-msg``) match the pre-sourcing-architecture
installs so ``--force`` knows to migrate them.
- ``ensure_notes_display_ref`` adds the
``notes.displayRef = refs/notes/mergify/*`` git config line
so ``git log`` surfaces the amend notes attached by
``mergify stack note``.
- ``HookAction`` log values let the binary handler render the
same per-hook lines Python printed
(``Installing hook wrapper: …`` /
``Updating managed hook script: mergify-hooks/<hook>.sh`` /
``Migrating legacy hook to new format: …`` /
``Found legacy hook: …``).
The (still-Python) ``stack push`` pre-flight used to call
``stack_setup_mod.stack_setup()`` and
``stack_setup_mod.ensure_hooks_updated()`` directly. With
``setup.py`` gone, those two calls in ``mergify_cli/stack/cli.py``
shell out to ``mergify stack setup`` instead — same behaviour,
goes through the native installer. The whole pre-flight block
goes away when ``stack push`` itself lands native.
Coverage: 6 lib tests over a tempdir-backed git repo —
``status`` reports all-missing on a fresh repo; ``install``
writes wrappers + scripts and is idempotent on a second run;
legacy wrappers report ``WrapperLegacyNeedsForce`` without
``--force`` and ``WrapperMigrated`` with it; user-written
wrappers (no ``mergify-hooks`` sentinel) are left untouched;
the ``notes.displayRef`` config line is added on first install.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: I12f4b4af3bf3dcae8002687f03eb55876c61170b
5a7352d to
e2ba308
Compare
8ee0f09 to
6229a79
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 both
mergify stack hooks(status--setup) andmergify stack setup(alias forhooks --setup, plus--check). The Python implementation(
mergify_cli/stack/setup.py, the click registrations, thetest_setup.pysuite, and the hook resource tree undermergify_cli/stack/hooks/) is removed. The hook scripts andwrappers are renamed to
crates/mergify-stack/hooks/{scripts, wrappers}/and embedded into the binary viainclude_str!.mergify_stack::commands::setup:upgraded from a Python install is recognised without
re-installation:
.git/hooks/<hook>is the thin wrapper(user-editable below the marker comment),
.git/hooks/mergify-hooks/<hook>.shis the managed script(always upgradable).
WrapperStatusdetection mirrors_get_wrapper_status:mergify-hooks+<hook>.shsubstring pair = ours;legacy heuristics (
Change-Id: I${random}oncommit-msg,is_amend_with_m_flagonprepare-commit-msg) match the pre-sourcing-architectureinstalls so
--forceknows to migrate them.ensure_notes_display_refadds thenotes.displayRef = refs/notes/mergify/*git config lineso
git logsurfaces the amend notes attached bymergify stack note.HookActionlog values let the binary handler render thesame per-hook lines Python printed
(
Installing hook wrapper: …/Updating managed hook script: mergify-hooks/<hook>.sh/Migrating legacy hook to new format: …/Found legacy hook: …).The (still-Python)
stack pushpre-flight used to callstack_setup_mod.stack_setup()andstack_setup_mod.ensure_hooks_updated()directly. Withsetup.pygone, those two calls inmergify_cli/stack/cli.pyshell out to
mergify stack setupinstead — same behaviour,goes through the native installer. The whole pre-flight block
goes away when
stack pushitself lands native.Coverage: 6 lib tests over a tempdir-backed git repo —
statusreports all-missing on a fresh repo;installwrites wrappers + scripts and is idempotent on a second run;
legacy wrappers report
WrapperLegacyNeedsForcewithout--forceandWrapperMigratedwith it; user-writtenwrappers (no
mergify-hookssentinel) are left untouched;the
notes.displayRefconfig line is added on first install.Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
Depends-On: #1524