61f92c81c5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TQd3pEP9UeN2uifbHknQ7B
25 lines
937 B
Bash
Executable File
25 lines
937 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Installs the Kvitt pre-commit hook into this repository's hooks folder (shared by all worktrees).
|
|
# The hook guards itself: on branches without android/ or server/ it only runs the secrets check.
|
|
# An earlier version of the Kvitt hook (recognised by its first comment line) is replaced; any other hook is kept.
|
|
set -euo pipefail
|
|
here="$(cd "$(dirname "$0")" && pwd)"
|
|
src="$here/git-hooks/pre-commit"
|
|
hooks="$(git -C "$here" rev-parse --path-format=absolute --git-common-dir)/hooks"
|
|
target="$hooks/pre-commit"
|
|
marker="# Kvitt pre-commit hook:"
|
|
if [[ -e "$target" ]]; then
|
|
if cmp -s "$src" "$target"; then
|
|
echo "Up to date: $target"
|
|
exit 0
|
|
fi
|
|
if ! sed -n 2p "$target" | grep -qF "$marker"; then
|
|
echo "A different pre-commit hook already exists at $target; not overwriting. Merge them by hand." >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
mkdir -p "$hooks"
|
|
cp "$src" "$target"
|
|
chmod +x "$target"
|
|
echo "Installed $target"
|