Current Situation
The script for checking the year of each copyright header is not applied to the main LICENSE file in this repository:
|
Copyright (c) 2019-2022 the Eclipse BaSyx Authors |
Moreover, the current solution for #451 introduced a small typo bug by mistaking the variable EXIT_CODE with ERROR_CODE. As a result, the script always terminates with EXIT_CODE=0, even when errors occur. This causes the CI pipeline to pass unconditionally:
|
EXIT_CODE=0 |
|
|
|
# Set CHECK_MODE based on whether --check is passed |
|
CHECK_MODE=false |
|
if [[ "$1" == "--check" ]]; then |
|
CHECK_MODE=true |
|
shift # Remove --check from the arguments |
|
fi |
|
|
|
while read -rd $'\0' year file; do |
|
|
|
# Extract the first year from the copyright notice |
|
current_year=$(sed -n '1,2s/^\(# Copyright (c) \)\([[:digit:]]\{4,\}\).*/\2/p' "$file") |
|
|
|
# Skip the file if no year is found |
|
if [[ -z "$current_year" ]]; then |
|
continue |
|
fi |
|
|
|
if $CHECK_MODE && [[ "$current_year" != "$year" ]]; then |
|
echo "Error: Copyright year mismatch in file $file. Expected $year, found $current_year." |
|
# Set ERROR_CODE to 1 to indicate mismatch |
|
ERROR_CODE=1 |
|
fi |
|
|
|
if ! $CHECK_MODE && [[ "$current_year" != "$year" ]]; then |
|
sed -i "1,2s/^\(# Copyright (c) \)[[:digit:]]\{4,\}/\1$year/" "$file" |
|
echo "Updated copyright year in $file" |
|
fi |
|
done < <(git ls-files -z "$@" | xargs -0I{} git log -1 -z --format="%cd {}" --date="format:%Y" -- "{}") |
|
|
|
exit $EXIT_CODE |
Proposed Change
Adapt set_copyright_year.sh to additionally parse LICENSE and check the current copyright year. Additionally, fix the variable typo.
Current Situation
The script for checking the year of each copyright header is not applied to the main
LICENSEfile in this repository:basyx-python-sdk/LICENSE
Line 3 in f831016
Moreover, the current solution for #451 introduced a small typo bug by mistaking the variable
EXIT_CODEwithERROR_CODE. As a result, the script always terminates withEXIT_CODE=0, even when errors occur. This causes the CI pipeline to pass unconditionally:basyx-python-sdk/etc/scripts/set_copyright_year.sh
Lines 17 to 48 in fa6a1b4
Proposed Change
Adapt
set_copyright_year.shto additionally parseLICENSEand check the current copyright year. Additionally, fix the variable typo.