#!/bin/sh # Install git hooks for this clone. Run once per clone (idempotent). # # ./scripts/install-hooks.sh # # After this, every `git push` runs ci-checks.sh + wiki-lint --strict and # rejects the push if the gate fails. Bypass only with --no-verify. set -eu repo_root="$(git rev-parse --show-toplevel)" src="${repo_root}/scripts/pre-push" [ -f "$src" ] || { echo "error: ${src} not found" >&2; exit 1; } chmod +x "$src" # --git-path resolves the real hooks dir even in worktrees / custom git dirs, # where .git is a file or the hooks live outside /.git/hooks. cd "$repo_root" hooks_dir="$(git rev-parse --git-path hooks)" mkdir -p "$hooks_dir" # Symlink to the absolute source path → robust regardless of where the hooks # dir actually lives (a relative target breaks for worktrees). ln -sf "$src" "${hooks_dir}/pre-push" echo "hooks installed: pre-push -> ${src}"