summaryrefslogtreecommitdiff
path: root/.husky
diff options
context:
space:
mode:
authorMaksims Svecovs <maksims.svecovs@arm.com>2023-03-15 13:24:44 +0000
committerMaksims Svecovs <maksims.svecovs@arm.com>2023-03-15 13:32:00 +0000
commit6bb49c876c7593ed5f61c20ef3d989dcff8e8d8c (patch)
treecb584c70f94126ccb270ca46b2cd032d59d089bc /.husky
parent4c985e867469523f91588a2f76bbb5ee5ca53d05 (diff)
style(hooks): adds Arm copyright style fix
Adds a check to pre-commit hook that makes sure "Arm" is written in a correct case and not "arm" or "ARM". Same as a copyright-year check, the hook will fix the issue and prompt user to stage the fix. Change-Id: I39db148d6621d542193f3ee703bddc23c7e8dc27 Signed-off-by: Maksims Svecovs <maksims.svecovs@arm.com>
Diffstat (limited to '.husky')
-rwxr-xr-x.husky/pre-commit.copyright12
1 files changed, 9 insertions, 3 deletions
diff --git a/.husky/pre-commit.copyright b/.husky/pre-commit.copyright
index b5087a746..a4dfee8e3 100755
--- a/.husky/pre-commit.copyright
+++ b/.husky/pre-commit.copyright
@@ -18,7 +18,7 @@ ARM_RGX="\(ARM\|Arm\|arm\)"
exit_code=0
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"
grep -nr "opyright.*$YEAR_RGX.*$ARM_RGX" "$FILE"
echo
@@ -38,15 +38,21 @@ while read -r FILE; do
if grep "opyright.*$YEAR_RGX.*-.*$YEAR_RGX.*$ARM_RGX" "$FILE" >/dev/null 2>&1
then
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
# 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
then
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
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
done <<< "$FILES"