-
Notifications
You must be signed in to change notification settings - Fork 44
/
.validateDCO
executable file
·42 lines (35 loc) · 1.09 KB
/
.validateDCO
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
#!/bin/bash
# This script will check to make sure each commit in PR, as specified
# by the TRAVIS_COMMIT_RANGE env var, is signed via a DCO
set -e
echo TRAVIS_COMMIT_RANGE: ${TRAVIS_COMMIT_RANGE}
if [[ "${TRAVIS_COMMIT_RANGE}" != *"..."* ]]; then
parent=$(git log -n 1 --format="%P" ${TRAVIS_COMMIT_RANGE})
TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE}...$parent"
fi
echo Commits: $(git rev-list ${TRAVIS_COMMIT_RANGE})
for commit in $(git rev-list ${TRAVIS_COMMIT_RANGE}); do
echo
echo Looking at commit: $commit
parents=$(git log -n 1 --format="%P" $commit)
if [[ "$parents" == *" "* ]]; then
echo "Skipping a merge commit"
continue
fi
set +e
git log --format="%B" -n 1 $commit | \
grep -E '^Signed-off-by: ' # ([^<]+) <([^<>@]+@[^<>]+)>$' > /dev/null 2>&1
if test ${PIPESTATUS[1]} -ne 0; then
set -e
echo "Commit msg:"
echo "------------------------------------"
git log --format="%B" -n 1 $commit
echo "------------------------------------"
echo "**** Commit $commit is missing a DCO"
exit 1
fi
set -e
done
echo
echo "**** All commits are signed!"
exit 0