Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to perform signoff check between commits #152

Merged
merged 3 commits into from
Mar 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions dev-tools/signoff-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/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 -ne 0 ]; then
echo !!! Commit "$commitId" is missing signoff, amend this commit with the --signoff flag
let "missingSignoff++"
peternied marked this conversation as resolved.
Show resolved Hide resolved
fi
done

# Return non-zero error code if any commits were missing signoff
exit $missingSignoff
peternied marked this conversation as resolved.
Show resolved Hide resolved