Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated validate-license.sh #13030

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 5 additions & 10 deletions scripts/validate-license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@
# limitations under the License.
set -euo pipefail
IFS=$'\n\t'

# removed -not to reduce complexity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can probably be removed since it is only applicable right now since -not is part of the existing validate-license.sh script.

# 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 . -not \( \
\( \
-wholename './vendor' \
-o -wholename '*testdata*' \
-o -wholename '*third_party*' \
\) -prune \
\) \
\( -name '*.go' -o -name '*.sh' \)
find . \
\( -path './vendor' -o -path '*/testdata/*' -o -path '*/third_party/*' \) -prune -o \
\( -name '*.go' -o -name '*.sh' \) -print
}

# 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")' || :))
if (( ${#failed_license_header[@]} > 0 )); then
Expand Down