Skip to content

feat(rust): port stack hooks + stack setup to native Rust#1527

Open
jd wants to merge 1 commit into
devs/jd/feat/rust-stack-new/port-stack-list-stack-open-native-rust--0a12ccb2from
devs/jd/feat/rust-stack-new/port-stack-hooks-stack-setup-native-rust--12f4b4af
Open

feat(rust): port stack hooks + stack setup to native Rust#1527
jd wants to merge 1 commit into
devs/jd/feat/rust-stack-new/port-stack-list-stack-open-native-rust--0a12ccb2from
devs/jd/feat/rust-stack-new/port-stack-hooks-stack-setup-native-rust--12f4b4af

Conversation

@jd

@jd jd commented Jun 4, 2026

Copy link
Copy Markdown
Member

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

Depends-On: #1524

@jd

jd commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(rust): port stack list + stack open to native Rust #1524
2 feat(rust): port stack hooks + stack setup to native Rust #1527 👈
3 feat(rust): port stack push end-to-end + delete Python push.py #1553
4 chore: delete Python tree + simplify wheel/CI for pure-Rust binary #1554
5 refactor(stack): extract shared git helpers into crate::git #1555
6 ci(workflows): align smoke-test-binary on python 3.14 #1557

@mergify

mergify Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 ⛓️ Depends-On Requirements

Waiting for

This rule is failing.

Requirement based on the presence of Depends-On in the body of the pull request

🔴 👀 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 4, 2026 10:37
@jd jd marked this pull request as ready for review June 4, 2026 12:15
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-hooks-stack-setup-native-rust--12f4b4af branch from d27f347 to 56cb890 Compare June 4, 2026 13:29
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-list-stack-open-native-rust--0a12ccb2 branch from f80abfe to 3b2e1b1 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 commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

Revision history

# Type Changes Reason Date
1 initial d27f347 2026-06-04 13:29 UTC
2 rebase d27f347 → 56cb890 (rebase only) 2026-06-04 13:29 UTC
3 rebase 56cb890 → e5c33cc (rebase only) 2026-06-05 07:01 UTC
4 rebase e5c33cc → d2bd9e8 (rebase only) 2026-06-05 08:13 UTC
5 rebase d2bd9e8 → 291e013 (rebase only) 2026-06-05 09:38 UTC
6 rebase 291e013 → 77e1b99 (rebase only) 2026-06-05 12:37 UTC
7 content 77e1b99 → 897e0bf (raw) 2026-06-08 11:31 UTC
8 rebase 897e0bf → cd3f76c (rebase only) 2026-06-08 15:03 UTC
9 rebase cd3f76c → 8ee0f09 (rebase only) 2026-06-09 07:12 UTC
10 rebase 8ee0f09 → 6229a79 (rebase only) 2026-06-09 12:37 UTC

@jd jd temporarily deployed to func-tests-live June 4, 2026 13:29 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 4, 2026 13:30 Failure
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-hooks-stack-setup-native-rust--12f4b4af branch from 56cb890 to e5c33cc Compare June 5, 2026 07:00
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-list-stack-open-native-rust--0a12ccb2 branch from 3b2e1b1 to 65aaa32 Compare June 5, 2026 07:00
@jd jd temporarily deployed to func-tests-live June 5, 2026 07:01 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live June 5, 2026 07:01 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 5, 2026 07:01 Failure
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-hooks-stack-setup-native-rust--12f4b4af branch from e5c33cc to d2bd9e8 Compare June 5, 2026 08:13
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-list-stack-open-native-rust--0a12ccb2 branch from 65aaa32 to b9ab524 Compare June 5, 2026 08:13
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 5, 2026 09:39 Failure
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-hooks-stack-setup-native-rust--12f4b4af branch from 291e013 to 77e1b99 Compare June 5, 2026 12:37
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-list-stack-open-native-rust--0a12ccb2 branch from fd18ff2 to 7106eca Compare June 5, 2026 12:37
@jd jd temporarily deployed to func-tests-live June 5, 2026 12:37 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live June 5, 2026 12:37 — with GitHub Actions Inactive
@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
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-hooks-stack-setup-native-rust--12f4b4af branch from 77e1b99 to 897e0bf 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 had a problem deploying to Mergify Merge Protections June 8, 2026 11:31 Failure
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-hooks-stack-setup-native-rust--12f4b4af branch from 897e0bf to cd3f76c Compare June 8, 2026 15:03
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-list-stack-open-native-rust--0a12ccb2 branch from cb73efd to b7ee9f5 Compare June 8, 2026 15:03
@jd jd temporarily deployed to func-tests-live June 8, 2026 15:03 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live June 8, 2026 15:03 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live June 8, 2026 15:03 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 8, 2026 15:03 Failure
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-list-stack-open-native-rust--0a12ccb2 branch from b7ee9f5 to 5a7352d Compare June 9, 2026 07:12
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-hooks-stack-setup-native-rust--12f4b4af branch from cd3f76c to 8ee0f09 Compare June 9, 2026 07:12
@jd jd temporarily deployed to func-tests-live June 9, 2026 07:12 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live June 9, 2026 07:12 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live June 9, 2026 07:12 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 9, 2026 07:12 Failure
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
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-list-stack-open-native-rust--0a12ccb2 branch from 5a7352d to e2ba308 Compare June 9, 2026 12:37
@jd jd force-pushed the devs/jd/feat/rust-stack-new/port-stack-hooks-stack-setup-native-rust--12f4b4af branch from 8ee0f09 to 6229a79 Compare June 9, 2026 12:37
@jd jd deployed to func-tests-live June 9, 2026 12:37 — with GitHub Actions Active
@jd jd temporarily deployed to func-tests-live June 9, 2026 12:37 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live June 9, 2026 12:37 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections June 9, 2026 12:38 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.

1 participant