#!/usr/bin/env bash
#
# Install the repository's git hooks. Run once after cloning.
# The hooks themselves live in bin/hooks/ so they are versioned and reviewable.
#
# Known weakness: this has to be run once per clone, and a missed run is silent —
# nothing tells you the hook is not there. See docs/TESTING.md.

set -euo pipefail

root=$( git rev-parse --show-toplevel )
target=$( git rev-parse --git-path hooks )

for hook in "$root"/bin/hooks/*; do
	name=$( basename "$hook" )
	ln -sf "../../bin/hooks/$name" "$target/$name"
	echo "installed: $name"
done
