From 67868f51bbab5bc3ef5c8ba15433ba401a297f1a Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Tue, 19 May 2026 16:45:17 +0100 Subject: feat(git): user-level hooks auto-dispatch into /.githooks/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inverts the hook delegation model. Previously per-repo hooks required a project to either (a) write the entire hook themselves and lose the global signed-commit / agent-author gate, or (b) override core.hooksPath and write passthrough stubs that exec back to $HOME/.config/git/hooks/*. Both are ergonomically miserable. Now: the global hooks at ~/.config/git/hooks/ are *always* the entry point. Each one calls a shared dispatcher (_dispatch.sh) that runs /.githooks/ if it exists, propagating its exit status, and then continues with whatever the global hook itself wants to do. Projects just drop an executable file at .githooks/ — no core.hooksPath, no stubs, no boilerplate. Repos that don't have a .githooks/ dir keep working exactly as before. GIT_HOOK_DISPATCHED guards against re-entry so legacy repos using the old stub-and-exec pattern don't loop. pre-push tees stdin so both the repo hook and the global ref-list loop see the full push payload. Adds two new always-no-op global hooks (pre-commit, post-commit) purely so the dispatch happens for those events too — previously only commit-msg and pre-push existed globally. Refactors this dotfiles repo to use the new pattern: drops the self-delegating .githooks/pre-push stub and removes the per-repo core.hooksPath override from `just init` (now an idempotent unsetter to clean up the override from past bootstraps). The remote-dev VM's home-manager profile symlinks all four hooks plus _dispatch.sh. --- dot_config/git/hooks/executable_pre-commit | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 dot_config/git/hooks/executable_pre-commit (limited to 'dot_config/git/hooks/executable_pre-commit') diff --git a/dot_config/git/hooks/executable_pre-commit b/dot_config/git/hooks/executable_pre-commit new file mode 100755 index 0000000..548925b --- /dev/null +++ b/dot_config/git/hooks/executable_pre-commit @@ -0,0 +1,15 @@ +#!/bin/sh +# User-level pre-commit. No global checks — exists purely so that +# `/.githooks/pre-commit` gets picked up automatically without +# the project needing to override core.hooksPath. If there is no +# per-repo hook this is a no-op. +# +# Bypass: git commit --no-verify + +set -eu + +# shellcheck source=./_dispatch.sh +. "${0%/*}/_dispatch.sh" +dispatch_repo_hook pre-commit "$@" + +exit 0 -- cgit v1.3.1