Repository navigation
fix(hooks): find the policy hooks from any install path - #10
Merged
Merged
Conversation
The dispatcher hardcoded ~/.config/git-policy/hooks, so a clone anywhere else installed hooks that never fired while the installer still printed "installed the hook dispatcher" and "set core.hooksPath". A commit on main then went through. The installer now records the real hooks directory in ~/.git-hooks/_policy and the dispatcher reads it, falling back to the documented path when the file is absent so the template still works on its own. A dispatcher that predates _policy is replaced, since it cannot be repointed; the installer says so and asks for local edits to be re-added. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
hook_active grepped the dispatcher for the string 'git-policy/hooks', which is present whether or not that path exists. So `rules check` reported "hooks 3/3 active" and "All checks passed" while the hooks were dead, which is the one thing the tool exists to catch. It now resolves the directory the dispatcher actually reads from _policy and requires an executable policy hook there. A stale pointer reports 0/3 active and exits 1. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
When hooks are inactive the cause is usually that the dispatcher looks in a directory the policy hooks are not in. `rules hooks` showed DISPATCH and HOOKSPATH but not the resolved policy directory, so that mismatch was invisible. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Nothing tested a clone outside ~/.config/git-policy, which is why the dispatcher bug went unnoticed, and `rules check` reported a false green that hid it. Five cases fail on the previous code: the recorded hooks directory, a commit on main actually being refused after an off-path install, a stale pointer reading as inactive, the health check exiting 1 for it, and an old dispatcher being replaced. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
The page showed the hardcoded ~/.config/git-policy path, which is what the dispatcher no longer does. It now shows the _policy lookup and says why the file exists. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
The section header still said a customised dispatcher is never replaced, which stopped being true when an old one started being swapped out. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
koryei
force-pushed
the
fix/dispatcher-finds-policy-hooks
branch
from
November 27, 2026 03:41
b1d3f89 to
465104d
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 bug
hooks/_dispatchhardcoded$HOME/.config/git-policy/hooks/$name. Clone therepo anywhere else, run
./install.sh, and it printed:…while every hook was dead. A commit on
mainwent straight through.Worse,
rules checkthen reportedhooks ✓ 3/3 activeandAll checks passed.It grepped the dispatcher for the string
git-policy/hooks, which is presentwhether or not that path exists. A false green on the one thing the tool exists
to enforce.
The fix
The installer records the real hooks directory in
~/.git-hooks/_policyand thedispatcher reads it, falling back to the documented path when the file is
absent — so the template still works on its own, and existing installs at the
documented path keep working.
hook_activenow resolves the directory the dispatcher actually reads andrequires an executable policy hook there, so a stale pointer reports
0/3andexits 1.
A dispatcher from before
_policycannot be repointed, so it is replaced andthe installer says so, asking for local edits to be re-added.
Commits
Each one is a single concern:
fix(hooks)_policy; installer writes it and upgrades old dispatchersfix(rules)feat(rules)rules hooksshows the resolvedPOLICYpathtestdocshow-it-works.mdshows the real lookupdocs(install)How to verify
The new cases fail on
main: I ran the updated suite against the pre-fixhooks/_dispatch,install.shandbin/rulesand got21 passed, 5 failed,including
hooks fire from another install path (want 1, got 0)— a commit onmainis now actually refused after an off-path install.Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe vibe@mistral.ai