#!/usr/bin/env bash # Installs the repository's git hooks into this checkout's shared hooks directory (one set for the main checkout and # every worktree, since worktrees share .git/hooks). Each hook is a two-line delegate to a versioned script, so a # change to the gate is a commit, never a reinstall: # pre-commit -> tools/ci/windows-paths-check.sh --staged (a path Windows cannot check out never enters a commit) # pre-push -> tools/ci/pre-push.sh --hook (the full CI gate before a push to master or release-*, # the two structural checks before any other push) # Neither hook writes into the worktree (the site is built in a temporary copy; 063bbca, 6 October 2026). # A tree that predates the scripts (an old branch) falls back to the conflict-marker check alone. set -euo pipefail cd "$(git rev-parse --show-toplevel)" hooks="$(git rev-parse --git-common-dir)/hooks"; mkdir -p "$hooks" cat > "$hooks/pre-push" <<'HOOK' #!/usr/bin/env bash # installed by tools/ci/install-hooks.sh; the gate itself is versioned in tools/ci/pre-push.sh (same script as CI) cd "$(git rev-parse --show-toplevel)" || exit 1 if [ -f tools/ci/pre-push.sh ]; then exec bash tools/ci/pre-push.sh --hook "$@"; fi exec bash tools/ci/no-conflict-markers.sh HOOK cat > "$hooks/pre-commit" <<'HOOK' #!/usr/bin/env bash # installed by tools/ci/install-hooks.sh; the check itself is versioned in tools/ci/windows-paths-check.sh cd "$(git rev-parse --show-toplevel)" || exit 1 [ -f tools/ci/windows-paths-check.sh ] || exit 0 exec bash tools/ci/windows-paths-check.sh --staged HOOK chmod +x "$hooks/pre-push" "$hooks/pre-commit" echo "hooks installed in $hooks: pre-commit (Windows paths of the staged files), pre-push (tools/ci/pre-push.sh --hook)"