#!/usr/bin/env bash
set -euo pipefail

repo_root="$(git rev-parse --show-toplevel)"
hook_dir="$repo_root/.git/hooks"
pre_commit_hook_path="$hook_dir/pre-commit"
hook_path="$hook_dir/pre-push"

mkdir -p "$hook_dir"

cat >"$pre_commit_hook_path" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail

repo_root="$(git rev-parse --show-toplevel)"
exec "$repo_root/scripts/git-hooks/pre-commit" "$@"
EOF

cat >"$hook_path" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail

repo_root="$(git rev-parse --show-toplevel)"
exec "$repo_root/scripts/git-hooks/pre-push" "$@"
EOF

chmod +x "$pre_commit_hook_path"
chmod +x "$hook_path"
echo "Installed pre-commit hook at $pre_commit_hook_path"
echo "Installed pre-push hook at $hook_path"
