8bef22afb2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.2 KiB
Bash
Executable File
29 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
||
# Kvitt pre-commit hook: the fast subset of `./gradlew check`. Installed by tools/install-git-hooks.sh.
|
||
set -e
|
||
top=$(git rev-parse --show-toplevel)
|
||
|
||
# Secrets and personal data never reach git. Adjust the list to this project (see CLAUDE.md › Never commit).
|
||
bad=$(git -C "$top" ls-files --cached -- local.properties '*.jks' '*.keystore' '*.p12' '*.aar' 'models/' 'export/' | head -5)
|
||
if [ -n "$bad" ]; then
|
||
echo "pre-commit: a secret, keystore, vendor binary or personal-data file is staged or tracked:" >&2
|
||
echo "$bad" >&2
|
||
echo "Unstage with: git rm --cached <file>" >&2
|
||
exit 1
|
||
fi
|
||
|
||
[ -x "$top/gradlew" ] || exit 0
|
||
|
||
# The build runs on the pinned JDK (gradle.properties); the shell's default java may be newer or a macOS stub.
|
||
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"
|
||
# Replace with this project's fast checks (architecture rules, the pure-module tests). Keep it under a minute.
|
||
./gradlew --quiet :core:model:test || {
|
||
echo "pre-commit: fast tests failed (see above). Run ./gradlew check for the full picture." >&2
|
||
exit 1
|
||
}
|