Skip to content

Commit

Permalink
Add script to check for signoff flag (#165) (#169)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>

Co-authored-by: Peter Nied <[email protected]>
  • Loading branch information
kavilla and peternied authored Mar 16, 2021
1 parent 1595ba7 commit 9516470
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions dev-tools/signoff-check.sh
Original file line number Diff line number Diff line change
@@ -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
missingSignoff=1
fi
done

# Return non-zero error code if any commits were missing signoff
exit $missingSignoff

0 comments on commit 9516470

Please sign in to comment.