mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
5cfc9c374c
see https://github.com/koalaman/shellcheck/wiki/SC2155 Looking at how these were used, I don't think we even need to export them, so removing that. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
55 lines
1.7 KiB
Bash
Executable file
55 lines
1.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "${SCRIPTDIR}/.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}
|
|
|
|
# "Username may only contain alphanumeric characters or dashes and cannot begin with a dash"
|
|
githubUsernameRegex='[a-zA-Z0-9][a-zA-Z0-9-]+'
|
|
|
|
# https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work
|
|
dcoPrefix='Signed-off-by:'
|
|
dcoRegex="^(Docker-DCO-1.1-)?$dcoPrefix ([^<]+) <([^<>@]+@[^<>]+)>( \\(github: ($githubUsernameRegex)\\))?$"
|
|
|
|
check_dco() {
|
|
grep -qE "$dcoRegex"
|
|
}
|
|
|
|
if [ ${adds} -eq 0 -a ${dels} -eq 0 ]; then
|
|
echo '0 adds, 0 deletions; nothing to validate! :)'
|
|
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
|
|
if ! git log -1 --format='format:%B' "$commit" | check_dco; then
|
|
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:'
|
|
echo ' https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work'
|
|
echo
|
|
} >&2
|
|
false
|
|
fi
|
|
fi
|