nextcloud-android/scripts/hooks/pre-commit
Álvaro Brey Vilas a38edb92dd
Improvements to git hooks
- pre-commit: Suppress all output and show reduced results.
   This is more concise and avoids unreadable errors when committing from an IDE
 - pre-push: Format with shell formatter, fix typo

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
2021-09-27 11:42:20 +02:00

14 lines
509 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 ktlint &>/dev/null; then
echo >&2 "Lint failed! See report at file://$(pwd)/build/ktlint.txt"
echo >&2 "Hint: fix most lint errors with ./gradlew ktlintFormat"
exit 1
fi
if ! ./gradlew --daemon detekt &>/dev/null; then
echo >&2 "Detekt failed! See report at file://$(pwd)/build/reports/detekt/detekt.html"
exit 1
fi