From 09be502159f2a57c789305a3f9a709f634b14d22 Mon Sep 17 00:00:00 2001 From: Will Pfleger Date: Fri, 10 Jul 2026 22:06:32 -0400 Subject: [PATCH] fix(dev): install Lefthook hooks into shared .git/hooks dir (#1751) Signed-off-by: Will Pfleger Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 --- Justfile | 11 +++++++++-- scripts/dev-setup.sh | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Justfile b/Justfile index e1988aea34..1059b6d96a 100644 --- a/Justfile +++ b/Justfile @@ -43,9 +43,16 @@ bootstrap: setup: bootstrap ./scripts/dev-setup.sh -# Install git hooks via lefthook +# Install git hooks via lefthook (dispatches from the shared .git/hooks dir so all +# linked worktrees inherit the same hooks without a worktree-relative .hooks path) hooks: - git config --local core.hooksPath .hooks + #!/usr/bin/env bash + set -euo pipefail + # --path-format=absolute guarantees an absolute path from every invocation context: + # without it, --git-common-dir returns ".git" from the main checkout and a + # relative hooksPath would break linked-worktree dispatch just like .hooks did. + HOOKS_DIR="$(git rev-parse --path-format=absolute --git-common-dir)/hooks" + git config --local core.hooksPath "$HOOKS_DIR" lefthook install --force # ⚠️ Wipe ALL data and recreate a clean environment diff --git a/scripts/dev-setup.sh b/scripts/dev-setup.sh index 09f22703d0..ae358517b3 100755 --- a/scripts/dev-setup.sh +++ b/scripts/dev-setup.sh @@ -169,7 +169,12 @@ fi # ---- Install git hooks ------------------------------------------------------ log "Installing git hooks..." -git config --local core.hooksPath .hooks +# Install into the shared .git/hooks directory using --path-format=absolute so the +# stored hooksPath is always an absolute path. Without it, --git-common-dir returns +# ".git" from the main checkout; a relative hooksPath would silently break +# linked-worktree dispatch (same failure mode as the old worktree-relative .hooks). +HOOKS_DIR="$(git -C "${REPO_ROOT}" rev-parse --path-format=absolute --git-common-dir)/hooks" +git -C "${REPO_ROOT}" config --local core.hooksPath "$HOOKS_DIR" lefthook install --force success "Git hooks installed"