2026-06-24 14:09:59 +02:00
|
|
|
#!/bin/sh
|
2026-06-24 14:13:06 +02:00
|
|
|
# Install git hooks for this clone. Run once per clone (idempotent).
|
2026-06-24 14:09:59 +02:00
|
|
|
#
|
|
|
|
|
# ./scripts/install-hooks.sh
|
|
|
|
|
#
|
2026-06-24 14:13:06 +02:00
|
|
|
# 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.
|
2026-06-24 14:09:59 +02:00
|
|
|
set -eu
|
|
|
|
|
|
2026-06-24 14:13:06 +02:00
|
|
|
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 <repo>/.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}"
|