Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/talk-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Scherzinger <info@andy-scherzinger.de>2022-03-17 15:47:27 +0300
committerAndy Scherzinger <info@andy-scherzinger.de>2022-03-17 15:47:27 +0300
commit70edda976fdd88a2ee59bc4c232703c82298a39e (patch)
treee3dbe9bab7cadc391293474290b666f3fae57980 /scripts
parenteb67a31bd1476974e6f8644313c68de181b286f2 (diff)
add hooks for commit/pushfeature/noid/ktlintPluginAndHooks
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/hooks/pre-commit14
-rw-r--r--scripts/hooks/pre-push27
2 files changed, 41 insertions, 0 deletions
diff --git a/scripts/hooks/pre-commit b/scripts/hooks/pre-commit
new file mode 100644
index 000000000..dad2ed4b7
--- /dev/null
+++ b/scripts/hooks/pre-commit
@@ -0,0 +1,14 @@
+#!/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 ktlintCheck &>/dev/null; then
+ echo >&2 "ktlint failed! Run ./gradlew ktlintCheck for details"
+ 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)/app/build/reports/detekt/detekt.html"
+ exit 1
+fi
diff --git a/scripts/hooks/pre-push b/scripts/hooks/pre-push
new file mode 100644
index 000000000..628975cb2
--- /dev/null
+++ b/scripts/hooks/pre-push
@@ -0,0 +1,27 @@
+#!/bin/bash
+# Pre-push: Don't allow commits without Signed-off-by. Skip with "git push --no-verify".
+set -euo pipefail
+
+z40=0000000000000000000000000000000000000000 # magic deleted ref
+
+while read local_ref local_sha remote_ref remote_sha; do
+ if [ "$local_sha" != $z40 ]; then
+ if [ "$remote_sha" = $z40 ]; then
+ # New branch, examine all commits
+ range="$(git merge-base master $local_sha)..$local_sha"
+ else
+ # Update to existing branch, examine new commits
+ range="$remote_sha..$local_sha"
+ fi
+
+ # Check for commits without sign-off
+ commit=$(git rev-list --no-merges --grep 'Signed-off-by' --invert-grep "$range")
+ if [ -n "$commit" ]; then
+ echo >&2 "Found commits without sign-off in $local_ref. Aborting push. Offending commits:"
+ echo >&2 "$commit"
+ exit 1
+ fi
+ fi
+done
+
+exit 0