This extends the update hook so that it enforces a requirement to have a
Signed-off-by line in every commit message. This can be optionally
turned off in individual repos by setting the "hooks.allowmissingsob"
git config variable.

Signed-off-by: Daniel P. Berrange <berra...@redhat.com>
---
 update | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/update b/update
index 6a8edcb..b7cfe7f 100755
--- a/update
+++ b/update
@@ -248,7 +248,21 @@ if [ $check_diff = yes ]; then
        if [ "$allow_bad_whitespace" != "true" ]; then
                test "$oldrev" = $zero \
                        && exit 0
-               exec git diff --check $oldrev $newrev --
+               git diff --check $oldrev $newrev --
+               test $? != 0 && exit 1
+       fi
+
+       allow_missing_sob=$(git config --bool hooks.allowmissingsob)
+       if [ "$allow_missing_sob" != "true" ]; then
+               for rev in `git log --format=%h $oldrev..$newrev`
+               do
+                       git show $rev | grep Signed-off-by >/dev/null 2>&1
+                       if test $? != 0
+                       then
+                               echo "*** Update hook: missing Signed-off-by 
tag in $rev" >&2
+                               exit 1
+                       fi
+               done
        fi
 fi
 
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to