forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsignoff-check.sh
executable file
·32 lines (26 loc) · 941 Bytes
/
signoff-check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
set -e -o pipefail
### 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