Merge "style(hooks): adds Arm copyright style fix" into integration

This commit is contained in:
Manish V Badarkhe 2023-03-15 17:51:42 +01:00 committed by TrustedFirmware Code Review
commit bde9280dcc

View file

@ -18,7 +18,7 @@ ARM_RGX="\(ARM\|Arm\|arm\)"
exit_code=0 exit_code=0
function user_warning() { function user_warning() {
echo -e "Copyright of $RED$FILE$BLANK is out of date" echo -e "Copyright of $RED$FILE$BLANK is out of date/incorrect"
echo -e "Updated copyright to" echo -e "Updated copyright to"
grep -nr "opyright.*$YEAR_RGX.*$ARM_RGX" "$FILE" grep -nr "opyright.*$YEAR_RGX.*$ARM_RGX" "$FILE"
echo echo
@ -38,15 +38,21 @@ while read -r FILE; do
if grep "opyright.*$YEAR_RGX.*-.*$YEAR_RGX.*$ARM_RGX" "$FILE" >/dev/null 2>&1 if grep "opyright.*$YEAR_RGX.*-.*$YEAR_RGX.*$ARM_RGX" "$FILE" >/dev/null 2>&1
then then
exit_code=1 exit_code=1
sed -i "s/\(opyright.*\)$YEAR_RGX\(.*$ARM_RGX\)/\1$(date +"%Y")\2/" $FILE sed -i "s/\(opyright.*\)$YEAR_RGX\(.*$ARM_RGX\)/\1$(date +"%Y"), Arm/" $FILE
user_warning user_warning
# If it is single "date" type of entry - add the copyright extension to current year. # If it is single "date" type of entry - add the copyright extension to current year.
elif grep "opyright.*$YEAR_RGX.*$ARM_RGX" "$FILE" >/dev/null 2>&1 elif grep "opyright.*$YEAR_RGX.*$ARM_RGX" "$FILE" >/dev/null 2>&1
then then
exit_code=1 exit_code=1
sed -i "s/\(opyright.*$YEAR_RGX\)\(.*$ARM_RGX\)/\1-$(date +"%Y")\2/" $FILE sed -i "s/\(opyright.*$YEAR_RGX\)\(.*$ARM_RGX\)/\1-$(date +"%Y"), Arm/" $FILE
user_warning user_warning
fi fi
# Even if the year is correct - verify that Arm copyright is formatted correctly.
elif grep "opyright.*\(ARM\|arm\)" "$FILE">/dev/null 2>&1
then
exit_code=1
sed -i "s/\(opyright.*\)\(ARM\|arm\)/\1Arm/" $FILE
user_warning
fi fi
done <<< "$FILES" done <<< "$FILES"