From 8b6ca52e87525bbbaf2f4e7b75d80b3104f753a0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 27 Aug 2017 22:32:18 +0200 Subject: [PATCH] Add applypatch-msg hook for Signed-off-by line checking --- .../hooks/applypatch-msg.check-signed-off.sh | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 scripts/hooks/applypatch-msg.check-signed-off.sh diff --git a/scripts/hooks/applypatch-msg.check-signed-off.sh b/scripts/hooks/applypatch-msg.check-signed-off.sh new file mode 100644 index 00000000..3cf81abb --- /dev/null +++ b/scripts/hooks/applypatch-msg.check-signed-off.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# +# An hook script to check the commit log message taken by +# applypatch from an e-mail message for proper "Signed-off-by" line(s). +# +# To enable this hook, copy this file to ".git/hooks/applypatch-msg" and make it +# executable. + +# +# This hook is used when applying patches which are send via mail, to verify the +# Signed-off-by line is in the commit message. +# + +. git-sh-setup + +RED='\e[0;31m' # Red +YELLOW='\e[0;33m' # Yellow +NORMAL='\e[0m' # Text Reset + +warn() { + echo -e >&2 "${YELLOW}$*${DEFAULT}" +} + +abort() { + echo -e >&2 "${RED}$*${DEFAULT}" + exit 1 +} + +headline=$(head -n 1 $1 | wc -c) +[[ $headline -gt 50 ]] && warn "Headline of patch longer than 50 chars" + +grep "^Signed-off-by" $1 >/dev/null 2>/dev/null && abort "No Signed-off-by line" +