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