Generalize tracked repo hook dispatch in protected-refs-policy #60

Closed
opened 2026-06-22 19:54:02 +01:00 by vnprc-agent · 0 comments
Contributor

run_cdk_tracked_hook in protected-refs-policy is hardcoded to $HOME/work/cdk and misc/git-hooks/pre-commit. It solves a real problem — running version-controlled hooks when core.hooksPath overrides .git/hooks/ — but the solution is repo-specific.

Proposed generic replacement: a .hookspath file in the repo root containing the relative path to the tracked hooks directory. The policy script reads it and dispatches $repo/$hookspath/$hook if it exists and is executable.

Example: cdk would get a .hookspath containing misc/git-hooks. No changes to the external project — we just add the file to our working copy (or gitignore it upstream and track it locally).

Steps:

  1. Add .hookspath lookup to run_tracked_hook replacing run_cdk_tracked_hook
  2. Fall back to $repo/.hooks/$hook if no .hookspath exists (zero-config convention)
  3. Add .hookspath to cdk checkout with content misc/git-hooks
  4. Update tests
  5. run_repo_hook (.git/hooks/$hook) stays as-is for untracked repo-local hooks
`run_cdk_tracked_hook` in `protected-refs-policy` is hardcoded to `$HOME/work/cdk` and `misc/git-hooks/pre-commit`. It solves a real problem — running version-controlled hooks when `core.hooksPath` overrides `.git/hooks/` — but the solution is repo-specific. Proposed generic replacement: a `.hookspath` file in the repo root containing the relative path to the tracked hooks directory. The policy script reads it and dispatches `$repo/$hookspath/$hook` if it exists and is executable. Example: cdk would get a `.hookspath` containing `misc/git-hooks`. No changes to the external project — we just add the file to our working copy (or gitignore it upstream and track it locally). Steps: 1. Add `.hookspath` lookup to `run_tracked_hook` replacing `run_cdk_tracked_hook` 2. Fall back to `$repo/.hooks/$hook` if no `.hookspath` exists (zero-config convention) 3. Add `.hookspath` to cdk checkout with content `misc/git-hooks` 4. Update tests 5. `run_repo_hook` (`.git/hooks/$hook`) stays as-is for untracked repo-local hooks
vnprc closed this issue 2026-06-24 03:56:48 +01:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
allod/tools#60
No description provided.