pre-commit hook: Android tests through gradle-serial.sh with JDK 25 on PATH, JAVA_HOME untouched; installer replaces an older Kvitt hook

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TQd3pEP9UeN2uifbHknQ7B
This commit is contained in:
2026-10-18 22:11:07 +02:00
parent 2fac1ecba0
commit 61f92c81c5
2 changed files with 18 additions and 11 deletions
+13 -4
View File
@@ -1,15 +1,24 @@
#!/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"
if [[ -e "$target" ]] && ! cmp -s "$here/git-hooks/pre-commit" "$target"; then
echo "A different pre-commit hook already exists at $target; not overwriting. Merge them by hand." >&2
exit 1
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 "$here/git-hooks/pre-commit" "$target"
cp "$src" "$target"
chmod +x "$target"
echo "Installed $target"