1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

validate: format vendor script with shfmt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit b9fd2cf605)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-08-26 18:31:23 +02:00
parent f1bd611d41
commit 51bf7da729
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -1,20 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPTDIR}/.validate" source "${SCRIPTDIR}/.validate"
validate_vendor_diff(){ validate_vendor_diff() {
IFS=$'\n' IFS=$'\n'
check_files=( 'vendor.sum' 'vendor.mod' 'vendor/' ) check_files=('vendor.sum' 'vendor.mod' 'vendor/')
# shellcheck disable=SC2207 # shellcheck disable=SC2207
changed_files=( $(validate_diff --diff-filter=ACMR --name-only -- "${check_files[@]}" || true) ) changed_files=($(validate_diff --diff-filter=ACMR --name-only -- "${check_files[@]}" || true))
unset IFS unset IFS
if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ "${#changed_files[@]}" -gt 0 ]; then if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ "${#changed_files[@]}" -gt 0 ]; then
# recreate vendor/ # recreate vendor/
./hack/vendor.sh ./hack/vendor.sh
# check if any files have changed # check if any files have changed
diffs="$(git status --porcelain -- "${check_files[@]}" 2>/dev/null)" diffs="$(git status --porcelain -- "${check_files[@]}" 2> /dev/null)"
mfiles="$(echo "$diffs" | awk '/^ M / {print $2}')" mfiles="$(echo "$diffs" | awk '/^ M / {print $2}')"
if [ "$diffs" ]; then if [ "$diffs" ]; then
{ {
@ -24,7 +24,7 @@ validate_vendor_diff(){
echo echo
echo 'Please vendor your package with hack/vendor.sh.' echo 'Please vendor your package with hack/vendor.sh.'
echo echo
if [ -n "$mfiles" ] ; then if [ -n "$mfiles" ]; then
git diff -- "$mfiles" git diff -- "$mfiles"
fi fi
} >&2 } >&2
@ -41,11 +41,11 @@ validate_vendor_diff(){
# 2. make sure all the packages contain license information (just warning, because it can cause false-positive) # 2. make sure all the packages contain license information (just warning, because it can cause false-positive)
validate_vendor_used() { validate_vendor_used() {
for f in $(mawk '$1 = "#" { print $2 }' 'vendor/modules.txt'); do for f in $(mawk '$1 = "#" { print $2 }' 'vendor/modules.txt'); do
if [ -d "vendor/$f" ]; then if [ -d "vendor/$f" ]; then
if ! echo "vendor/$f"/* | grep -qiEc '/(LICENSE|COPYING)'; then if ! echo "vendor/$f"/* | grep -qiEc '/(LICENSE|COPYING)'; then
echo "WARNING: could not find copyright information for $f" echo "WARNING: could not find copyright information for $f"
fi
fi fi
fi
done done
} }