summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-10-26 16:39:21 +0200
committerMatthias Beyer <mail@beyermatthias.de>2018-10-31 17:15:29 +0100
commit4bc25c3b80432e0c454025989a6c51bfa66fb034 (patch)
tree0ddc62fe967d44ce9d0f8459973903e9db0a452d /scripts
parent366ca62eb9c25cdbf12a2be807b645203b772acd (diff)
Add sendemail-validate hook for checking signoffby lines
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/hooks/sendemail-validate.signoffby-missing-warn.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/hooks/sendemail-validate.signoffby-missing-warn.sh b/scripts/hooks/sendemail-validate.signoffby-missing-warn.sh
new file mode 100644
index 00000000..386571e2
--- /dev/null
+++ b/scripts/hooks/sendemail-validate.signoffby-missing-warn.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+
+#
+# The following snippet can be used to _WARN_ if a Signed-off-by line is missing
+# in the commit message of the patch
+#
+# Use
+#
+# git config sendemail.validate true
+#
+# and link this script to your git hooks folder to enable.
+#
+
+GREEN='\e[0;32m' # Green
+RED='\e[0;31m' # Red
+NORMAL='\e[0m' # Text Reset
+
+GREPLINE="^Signed-off-by: $(git config user.name) <$(git config user.email)>"
+
+if [ "$(grep -c "$GREPLINE" "$1")" -lt 1 ]; then
+ echo -e >&2 "${RED}Missing Signed-off-by line.${NORMAL}\n"
+
+ # To not only warn, but abort the patch sending, uncomment the next line
+ # exit 1
+else
+ echo -e >&2 "${GREEN}Signed-off-by line found.${NORMAL}\n"
+fi
+