2022-01-06 21:51:52 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Checks if the license header is correct
|
|
|
|
#
|
|
|
|
|
|
|
|
[[ -z "${CHANGED_FILES}" ]] && exit 0
|
|
|
|
|
2022-01-07 00:03:05 +01:00
|
|
|
IFS=' ' read -ra files <<<"${CHANGED_FILES//$'\n'/ }"
|
|
|
|
|
2022-01-06 21:51:52 +01:00
|
|
|
current_year=$(date +"%Y")
|
|
|
|
php_template_md5=$(sed "s/%%YEAR%%/$current_year/g" "mods/license/license_php.template" | md5sum)
|
|
|
|
php_template_rows=$(wc -l "mods/license/license_php.template" | cut -d" " -f1)
|
|
|
|
|
|
|
|
exitVal=0
|
|
|
|
|
2022-01-07 00:03:05 +01:00
|
|
|
printf "\n"
|
|
|
|
|
|
|
|
for file in "${files[@]}"; do
|
2022-01-22 19:32:54 +01:00
|
|
|
if [ ! -f "$file" ] || [[ "$file" == *strings.php ]]; then
|
2022-01-16 20:48:11 +01:00
|
|
|
continue
|
|
|
|
fi
|
2022-01-06 21:51:52 +01:00
|
|
|
php_license_md5=$(head -n "$php_template_rows" "$file" | md5sum)
|
|
|
|
[[ "$php_template_md5" != "$php_license_md5" ]] && printf " - %s\n" "$file" && exitVal=1
|
|
|
|
done
|
|
|
|
|
|
|
|
[[ $exitVal != 0 ]] && echo "License headers are missing or wrong"
|
|
|
|
|
|
|
|
exit $exitVal
|