From 29d5b00addaec3a8857557737de074e179bfccd9 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Mon, 1 Mar 2021 14:24:10 -0600 Subject: [PATCH] Add script to perform signoff check between commits (#152) * Add script to perform signoff check between commits Signed-off-by: Peter Nied --- dev-tools/signoff-check.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 dev-tools/signoff-check.sh diff --git a/dev-tools/signoff-check.sh b/dev-tools/signoff-check.sh new file mode 100755 index 0000000000000..56cb49455165e --- /dev/null +++ b/dev-tools/signoff-check.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +### Script to check for signoff presents on commits + +# Validate input parameters +if [ -z $1 ] || [ -z $2 ] +then + echo usage: ./signoff-check.sh commit1 commit2 + echo + echo Checks all of the commits between commit1 \(exclusive\) and commit2 \(inclusive\) + echo were made with the --signoff flag enabled + exit 1 +fi + +# Get the list of commit ids to check from git +commits=$(git rev-list $1..$2) + +# Scan each commit for the sign off message +missingSignoff=0 +for commitId in $commits; do + commitMessage=$(git rev-list --format=%B --max-count=1 $commitId) + signoffStringCount=$(echo $commitMessage | grep -c Signed-off-by) + if [ $signoffStringCount -eq 0 ]; then + echo !!! Commit "$commitId" is missing signoff, amend this commit with the --signoff flag + let "missingSignoff++" + fi +done + +# Return non-zero error code if any commits were missing signoff +exit $missingSignoff +