From 036398f512621b4128942ff62f697cfb4b4b9bc6 Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Mon, 14 Nov 2022 15:20:01 -0700 Subject: [PATCH] hack/validate/vendor: clean up license validation step Signed-off-by: Bjorn Neergaard (cherry picked from commit 9f004830a5c5c742ef5c2dec5468956f729b59a0) Signed-off-by: Bjorn Neergaard --- hack/validate/vendor | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hack/validate/vendor b/hack/validate/vendor index 8c589b0e59..a0b35d3f25 100755 --- a/hack/validate/vendor +++ b/hack/validate/vendor @@ -24,25 +24,26 @@ validate_vendor_diff() { # check if any files have changed git diff --quiet HEAD -- "${vendor_files[@]}" else - echo >&2 'No vendor changes in diff; skipping vendor check.' + echo >&2 'INFO: no vendor changes in diff; skipping vendor check.' fi } validate_vendor_license() { - for f in $(mawk '$1 = "#" { print $2 }' 'vendor/modules.txt'); do - if [ -d "vendor/$f" ]; then - if ! echo "vendor/$f"/* | grep -qiEc '/(LICENSE|COPYING)'; then - echo >&2 "WARNING: could not find copyright information for $f" - fi + while IFS= read -r module; do + test -d "vendor/$module" || continue + if ! compgen -G "vendor/$module/*" | grep -qEi '/(LICENSE|COPYING)[^/]*$'; then + echo >&2 "WARNING: could not find copyright information for $module" fi - done + done < <(awk '/^# /{ print $2 }' vendor/modules.txt) } if validate_vendor_tidy && validate_vendor_diff && validate_vendor_license; then - echo >&2 'Vendoring has been performed correctly!' + echo >&2 'PASS: Vendoring has been performed correctly!' else { - echo 'Vendoring was not performed correctly; the following files changed during re-vendor:' + echo 'FAIL: Vendoring was not performed correctly!' + echo + echo 'The following files changed during re-vendor:' echo git diff --name-status HEAD -- "${vendor_files[@]}" echo