jenkins: improve checksignedoffby to be more explicit and friendly
authorJean Privat <jean@pryen.org>
Wed, 19 Aug 2015 06:55:53 +0000 (02:55 -0400)
committerJean Privat <jean@pryen.org>
Wed, 19 Aug 2015 18:34:13 +0000 (14:34 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

misc/jenkins/checksignedoffby.sh

index bebd200..9a5c27f 100755 (executable)
 # 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