fix copyright year check if only submodules bumped (#4879)

When only submodules were bumped but no other changes are committed,
`git diff` returns empty list, and `grep` returns 1. Suppress `grep`
error to prevent CI fail in that case.
This commit is contained in:
Etan Kissling 2023-04-29 20:39:39 +02:00 committed by GitHub
parent 5ccb085b9b
commit ee1bda63fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -68,12 +68,12 @@ jobs:
base_branch=$(jq -r '.pull_request.base.ref' "$GITHUB_EVENT_PATH")
git fetch origin "$base_branch" 2>/dev/null
modified_files=$(git diff --name-only --diff-filter=d --ignore-submodules "origin/$base_branch" HEAD | grep -vE '\.('$excluded_extensions')$')
modified_files=$(git diff --name-only --diff-filter=d --ignore-submodules "origin/$base_branch" HEAD | grep -vE '\.('$excluded_extensions')$' || true)
current_year=$(date +"%Y")
outdated_files=()
for file in $modified_files; do
if ! grep -qE "Copyright \(c\) .*$current_year Status Research & Development GmbH" "$file"; then
if ! grep -qE 'Copyright \(c\) .*'$current_year' Status Research & Development GmbH' "$file"; then
outdated_files+=("$file")
fi
done