2014-04-04 06:37:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source "$(dirname "$BASH_SOURCE")/.validate"
|
|
|
|
|
|
|
|
adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
|
|
|
|
dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }')
|
|
|
|
notDocs="$(validate_diff --numstat | awk '$3 !~ /^docs\// { print $3 }')"
|
|
|
|
|
|
|
|
: ${adds:=0}
|
|
|
|
: ${dels:=0}
|
|
|
|
|
2014-07-07 14:32:09 +00:00
|
|
|
# "Username may only contain alphanumeric characters or dashes and cannot begin with a dash"
|
2014-07-07 15:57:50 +00:00
|
|
|
githubUsernameRegex='[a-zA-Z0-9][a-zA-Z0-9-]+'
|
2014-07-07 14:32:09 +00:00
|
|
|
|
2014-07-24 22:19:50 +00:00
|
|
|
# https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work
|
2014-07-07 14:32:09 +00:00
|
|
|
dcoPrefix='Docker-DCO-1.1-Signed-off-by:'
|
|
|
|
dcoRegex="^$dcoPrefix ([^<]+) <([^<>@]+@[^<>]+)> \\(github: ($githubUsernameRegex)\\)$"
|
|
|
|
|
|
|
|
check_dco() {
|
|
|
|
grep -qE "$dcoRegex"
|
|
|
|
}
|
|
|
|
|
2014-04-04 06:37:50 +00:00
|
|
|
if [ $adds -eq 0 -a $dels -eq 0 ]; then
|
|
|
|
echo '0 adds, 0 deletions; nothing to validate! :)'
|
|
|
|
elif [ -z "$notDocs" -a $adds -le 1 -a $dels -le 1 ]; then
|
|
|
|
echo 'Congratulations! DCO small-patch-exception material!'
|
|
|
|
else
|
|
|
|
commits=( $(validate_log --format='format:%H%n') )
|
|
|
|
badCommits=()
|
|
|
|
for commit in "${commits[@]}"; do
|
|
|
|
if [ -z "$(git log -1 --format='format:' --name-status "$commit")" ]; then
|
|
|
|
# no content (ie, Merge commit, etc)
|
|
|
|
continue
|
|
|
|
fi
|
2014-07-07 14:32:09 +00:00
|
|
|
if ! git log -1 --format='format:%B' "$commit" | check_dco; then
|
2014-04-04 06:37:50 +00:00
|
|
|
badCommits+=( "$commit" )
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ ${#badCommits[@]} -eq 0 ]; then
|
|
|
|
echo "Congratulations! All commits are properly signed with the DCO!"
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "These commits do not have a proper '$dcoPrefix' marker:"
|
|
|
|
for commit in "${badCommits[@]}"; do
|
|
|
|
echo " - $commit"
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
echo 'Please amend each commit to include a properly formatted DCO marker.'
|
|
|
|
echo
|
|
|
|
echo 'Visit the following URL for information about the Docker DCO:'
|
2014-07-24 22:19:50 +00:00
|
|
|
echo ' https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work'
|
2014-04-04 06:37:50 +00:00
|
|
|
echo
|
|
|
|
} >&2
|
|
|
|
false
|
|
|
|
fi
|
|
|
|
fi
|