| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Redirect output to stderr. |
| 4 |
exec 1>&2 |
| 5 |
|
| 6 |
check_failed=false |
| 7 |
|
| 8 |
# Do the code format check |
| 9 |
if ! "$(git rev-parse --show-toplevel)/scripts/code-format/check-format.sh" HEAD 1>&2; then |
| 10 |
printf "\n\033[31mFailed\033[0m: code format check.\n" |
| 11 |
check_failed=true |
| 12 |
fi |
| 13 |
|
| 14 |
# Do the copyright check |
| 15 |
# update & apply copyright when hook config is set, otherwise just verify |
| 16 |
opts="-qc" |
| 17 |
if [ "$(git config --get --type bool --default false hooks.updateCopyright)" = "true" ]; then |
| 18 |
opts="-qca" |
| 19 |
fi |
| 20 |
|
| 21 |
if ! "$(git rev-parse --show-toplevel)/scripts/copyright-date/check-copyright.sh" "$opts" 1>&2; then |
| 22 |
printf "\n\033[31mFailed\033[0m: copyright date check.\n" |
| 23 |
check_failed=true |
| 24 |
fi |
| 25 |
|
| 26 |
if $check_failed; then |
| 27 |
printf " |
| 28 |
Pre-commit check failed, please fix the reported errors. |
| 29 |
Note: Use '\033[33mgit commit --no-verify\033[0m' to bypass checks.\n" |
| 30 |
exit 1 |
| 31 |
fi |