-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·24 lines (19 loc) · 899 Bytes
/
Copy pathpre-commit
File metadata and controls
executable file
·24 lines (19 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
# Pre-commit hook: don't allow commits if detekt or ktlint fail. Skip with "git commit --no-verify".
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2021 Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
# SPDX-License-Identifier: GPL-3.0-or-later
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)/library/build/reports/detekt/detekt.html"
exit 1
fi
if ! ./gradlew compileUnitTestSources compileDebugAndroidTestSources; then
echo >&2 "Compilation of unit test and androidTest code failed!"
exit 1
fi