From ffa7c819b7c34394c33f3e24f7fd197d0f3b9272 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 19 Aug 2015 02:55:53 -0400 Subject: [PATCH] jenkins: improve checksignedoffby to be more explicit and friendly Signed-off-by: Jean Privat --- misc/jenkins/checksignedoffby.sh | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/misc/jenkins/checksignedoffby.sh b/misc/jenkins/checksignedoffby.sh index bebd200..9a5c27f 100755 --- a/misc/jenkins/checksignedoffby.sh +++ b/misc/jenkins/checksignedoffby.sh @@ -14,36 +14,47 @@ # limitations under the License. # Check missing signed-off-by in commits +# Usage: checksignedoffby from to -if test "$#" -lt 2; then - echo "Usage: checksignedoffby from to" - echo "" - exit -fi +set -e -from=$1 -to=$2 +from=${1:-origin/master} +to=${2:-HEAD} err=0 +cd `git rev-parse --show-toplevel` + +echo "checksignedoffby $from (`git rev-parse "$from"`) .. $to (`git rev-parse "$to"`)" for ref in `git rev-list --no-merges "$from".."$to"`; do # What is the expected? sig=`git --no-pager show -s --format='Signed-off-by: %an <%ae>' $ref` # Do we found some signed-off-by? git --no-pager show -s --format="%b" $ref | grep "^Signed-off-by:" > check_signedoff_list.out || { + echo "" + echo "Missing $sig for commit" git --no-pager show -s --oneline $ref - echo "Missing $sig" err=1 continue } # Do we found the expected thing? cat check_signedoff_list.out | grep -q "^$sig\$" && continue + echo "" + echo "Bad or missing Signed-off-by for commit" git --no-pager show -s --oneline $ref - echo "Bad or missing $sig; got:" + echo "Expected (from local git config):" + echo "$sig" + echo "Got:" cat check_signedoff_list.out err=1 done rm check_signedoff_list.out 2> /dev/null +if test "$err" = 1; then + echo "" + echo "Please check that each commit contains a \`Signed-off-by:\` statement that matches the author's name and email." + echo "Note that existing commits should be amended; pushing new commit is not sufficient." +fi + exit $err -- 1.7.9.5