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
+5 -7
View File
@@ -14,13 +14,11 @@ if [ -n "$bad" ]; then
exit 1
fi
# Android: the pure model tests, on the pinned JDK (android/gradle.properties); the shell's java may be a stub.
if [ -x "$top/android/gradlew" ] && [ -d "$top/android/core/model" ]; then
case "$("${JAVA_HOME:+$JAVA_HOME/bin/}java" -version 2>&1 | head -1)" in
*\"25*) ;;
*) [ -d /opt/homebrew/opt/openjdk@25 ] && export JAVA_HOME=/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home ;;
esac
(cd "$top/android" && ./gradlew --quiet :core:model:test :domain:test) || {
# Android: the pure model tests, through the one-build-at-a-time lock, with JDK 25 first on PATH and JAVA_HOME
# untouched (CLAUDE.md › Build and verify); the shell's java may be a stub.
if [ -x "$top/android/gradlew" ] && [ -d "$top/android/core/model" ] && [ -x "$top/tools/gradle-serial.sh" ]; then
[ -d /opt/homebrew/opt/openjdk@25/bin ] && PATH="/opt/homebrew/opt/openjdk@25/bin:$PATH"
"$top/tools/gradle-serial.sh" --quiet :core:model:test :domain:test || {
echo "pre-commit: Android fast tests failed (see above). Run tools/gradle-serial.sh check for the full picture." >&2
exit 1
}
+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"