nextcloud-android/scripts/hooks/pre-commit
Álvaro Brey b201b3a090
Update pre-commit hook to use spotless for kotlin
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
2022-10-07 17:43:48 +02:00

14 lines
538 B
Bash
Executable file

#!/bin/bash
# Pre-commit hook: don't allow commits if detekt or ktlint fail. Skip with "git commit --no-verify".
echo "Running pre-commit checks..."
if ! ./gradlew --daemon spotlessKotlinCheck &>/dev/null; then
echo >&2 "ktlint failed! Run ./gradlew spotlessKotlinCheck for details"
echo >&2 "Hint: fix most lint errors with ./gradlew spotlessKotlinApply"
exit 1
fi
if ! ./gradlew --daemon detekt &>/dev/null; then
echo >&2 "Detekt failed! See report at file://$(pwd)/app/build/reports/detekt/detekt.html"
exit 1
fi