fix(dev): install Lefthook hooks into shared .git/hooks dir (#1751)

Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
Will Pfleger
2026-07-10 22:06:32 -04:00
committed by GitHub
parent ec37625522
commit 09be502159
2 changed files with 15 additions and 3 deletions

View File

@@ -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

View File

@@ -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"