#!/bin/bash # install-hooks.sh - installs the repository-local git hooks that run the # excluded-terms check before every commit (staged files) and on every commit # message. The machine's global hook dispatcher runs these after its own rules. # Run once per clone. bash 3.2 safe, ASCII only. set -eu ROOT=$(git rev-parse --show-toplevel) HOOKS="$(git rev-parse --git-common-dir)/hooks" mkdir -p "$HOOKS" printf '#!/bin/bash\nexec "%s/tools/check-excluded-terms.sh" --staged\n' "$ROOT" > "$HOOKS/pre-commit" printf '#!/bin/bash\nexec "%s/tools/check-excluded-terms.sh" --message "$1"\n' "$ROOT" > "$HOOKS/commit-msg" chmod +x "$HOOKS/pre-commit" "$HOOKS/commit-msg" echo "installed: $HOOKS/pre-commit, $HOOKS/commit-msg"