1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/hack/validate/vendor
Sebastiaan van Stijn c3650770cc
Revert "Bash scripts; use double brackets, fix bare variables, add quotes"
This reverts commit 297b30df5f.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-10 02:23:38 +01:00

51 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${SCRIPTDIR}/.validate"
validate_vendor_diff(){
IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'vendor.conf' 'vendor/' || true) )
unset IFS
if [ ${#files[@]} -gt 0 ]; then
# recreate vendor/
vndr
# check if any files have changed
diffs="$(git status --porcelain -- vendor 2>/dev/null)"
if [ "$diffs" ]; then
{
echo 'The result of vndr differs'
echo
echo "$diffs"
echo
echo 'Please vendor your package with github.com/LK4D4/vndr.'
echo
} >&2
false
else
echo 'Congratulations! All vendoring changes are done the right way.'
fi
else
echo 'No vendor changes in diff.'
fi
}
# 1. make sure all the vendored packages are used
# 2. make sure all the packages contain license information (just warning, because it can cause false-positive)
validate_vendor_used() {
pkgs=$(mawk '/^[a-zA-Z0-9]/ { print $1 }' < vendor.conf)
for f in $pkgs; do
if ls -d vendor/$f > /dev/null 2>&1; then
found=$(find vendor/$f -iregex '.*LICENSE.*' -or -iregex '.*COPYRIGHT.*' -or -iregex '.*COPYING.*' | wc -l)
if [ $found -eq 0 ]; then
echo "WARNING: could not find copyright information for $f"
fi
else
echo "WARNING: $f is vendored but unused"
fi
done
}
validate_vendor_diff
validate_vendor_used