File size: 680 Bytes
7766f0b
7197abd
7766f0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/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)"