Merge pull request #1 from Saahiti402/Saahiti402-patch-2

Update validate-license.sh
pull/13030/head
Saahiti402 6 months ago committed by GitHub
commit 766305121f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -15,18 +15,13 @@
# limitations under the License. # limitations under the License.
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'
# removed -not to reduce complexity
# This function searches for files in the current directory and its subdirectories, excluding specific directories (vendor, testdata, and third_party), and then prints the files with .go or .sh extensions
find_files() { find_files() {
find . -not \( \ find . \
\( \ \( -path './vendor' -o -path '*/testdata/*' -o -path '*/third_party/*' \) -prune -o \
-wholename './vendor' \ \( -name '*.go' -o -name '*.sh' \) -print
-o -wholename '*testdata*' \
-o -wholename '*third_party*' \
\) -prune \
\) \
\( -name '*.go' -o -name '*.sh' \)
} }
# Use "|| :" to ignore the error code when grep returns empty # Use "|| :" to ignore the error code when grep returns empty
failed_license_header=($(find_files | xargs grep -L 'Licensed under the Apache License, Version 2.0 (the "License")' || :)) failed_license_header=($(find_files | xargs grep -L 'Licensed under the Apache License, Version 2.0 (the "License")' || :))
if (( ${#failed_license_header[@]} > 0 )); then if (( ${#failed_license_header[@]} > 0 )); then

Loading…
Cancel
Save