#!/usr/bin/env bash # Thanatos-27B — install scripts/check.sh as a git pre-commit hook. # # Idempotent. Re-runs are safe. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" HOOK_DIR="${ROOT}/.git/hooks" HOOK="${HOOK_DIR}/pre-commit" if [[ ! -d "${HOOK_DIR}" ]]; then echo "[!] ${HOOK_DIR} not found. Are you in the repo root?" >&2 exit 1 fi cat > "${HOOK}" <<'EOF' #!/usr/bin/env bash # Auto-installed by scripts/install-hooks.sh. set -e ROOT="$(git rev-parse --show-toplevel)" exec "${ROOT}/scripts/check.sh" EOF chmod +x "${HOOK}" echo "[+] installed pre-commit hook -> ${HOOK}" echo " (it will run scripts/check.sh on every git commit)"