2021-09-24 14:07:11 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
# Pre-commit hook: don't allow commits if detekt or ktlint fail. Skip with "git commit --no-verify".
|
2024-03-29 16:56:51 +01:00
|
|
|
|
|
|
|
|
|
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
# SPDX-FileCopyrightText: 2021 <20>lvaro Brey Vilas <alvaro.brey@nextcloud.com>
|
2024-03-29 19:22:56 +01:00
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
2024-03-29 16:56:51 +01:00
|
|
|
|
|
2022-03-16 11:20:30 +01:00
|
|
|
|
echo "Running pre-commit checks..."
|
2021-09-24 14:07:11 +02:00
|
|
|
|
|
2022-10-07 17:43:48 +02:00
|
|
|
|
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"
|
2021-09-27 11:40:01 +02:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ! ./gradlew --daemon detekt &>/dev/null; then
|
2022-03-11 11:42:11 +01:00
|
|
|
|
echo >&2 "Detekt failed! See report at file://$(pwd)/app/build/reports/detekt/detekt.html"
|
2021-09-27 11:40:01 +02:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|