-
Notifications
You must be signed in to change notification settings - Fork 18
/
cla-check.sh
executable file
·62 lines (48 loc) · 1.7 KB
/
cla-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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -e
CLA_URL="https://github.com/shapesecurity/CLA"
if [ $# -gt 0 ]; then
CLA_CSV_URL="$1"
CSV_DATA=`cat "$1" | tail -n +2`
else
CLA_CSV_URL="https://raw.githubusercontent.com/shapesecurity/CLA/HEAD/CONTRIBUTORS.csv"
CSV_DATA=`curl "$CLA_CSV_URL" 2>/dev/null | tail -n +2`
fi
if [ -z "$COMMIT_RANGE" ]; then
echo "COMMIT_RANGE must be provided"
exit 1
fi
echo "CLA_CSV_URL: $CLA_CSV_URL"
echo "COMMIT_RANGE: $COMMIT_RANGE"
echo
CONTRIBUTORS=(`echo "$CSV_DATA" | awk -F, '/,/{gsub(/ /, "", $0); print $2 "@users.noreply.github.com"; print $4}'`)
CONTRIBUTORS=" ${CONTRIBUTORS[*]} "
AUTHORS=(`git log --pretty=format:"%ae" $COMMIT_RANGE | sort -u`)
echo "Authors in this range: ${AUTHORS[@]}"
for item in ${AUTHORS[@]}; do
if [[ ! ("$item" == *"@shapesecurity.com" || "$item" == *"@f5.com" || "$item" == *"+dependabot[bot]@users.noreply.github.com" || "$CONTRIBUTORS" =~ " $item ") ]]; then
echo
echo "ERROR: Author $item has not signed the CLA"
echo
result+=($item)
fi
done
COMMITTERS=(`git log --pretty=format:"%ce" $COMMIT_RANGE | sort -u`)
echo "Committers in this range: ${COMMITTERS[@]}"
for item in ${COMMITTERS[@]}; do
if [[ ! ("$item" == "[email protected]" || "$item" == *"@shapesecurity.com" || "$item" == *"@f5.com" || "$CONTRIBUTORS" =~ " $item ") ]]; then
echo
echo "ERROR: Committer $item has not signed the CLA"
echo
result+=($item)
fi
done
echo
if [ ${#result[@]} -gt 0 ]; then
echo "Please submit a PR to the CLA located at $CLA_URL"
echo
echo "Debug info:"
git log -1 --format="Commit: %H%nParents: %P%nSubject: %s%nAuthor: %an <%ae>%nAuthor Date: %ad%nCommitter: %cn <%ce>%nCommitter Date: %cd"
exit 1
fi
echo "CLA check succeeded"