[HOOKS] Update pre-commit script to check for missing documentation in functions

This commit is contained in:
Hugo Sales 2020-11-06 16:50:42 +00:00 committed by Hugo Sales
parent de8fa87079
commit 67d4702743
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 13 additions and 6 deletions

1
bin/php-cs-fixer Symbolic link
View File

@ -0,0 +1 @@
../vendor/bin/php-cs-fixer

1
bin/php-doc-check Symbolic link
View File

@ -0,0 +1 @@
../vendor/bin/php-doc-check

View File

@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# get the list of changed files root="$(git rev-parse --show-toplevel)"
staged_files=$(git diff --cached --name-only)
# build command to fix files # get the list of changed files
cmd="$(git rev-parse --show-toplevel)/vendor/bin/php-cs-fixer" staged_files="$(git diff --cached --name-only)"
echo "Running php-cs-fixer on edited files" echo "Running php-cs-fixer on edited files"
@ -12,7 +12,7 @@ for staged in ${staged_files}; do
# work only with existing files # work only with existing files
if [[ -f ${staged} && ${staged} == *.php ]]; then if [[ -f ${staged} && ${staged} == *.php ]]; then
# use php-cs-fixer and get flag of correction # use php-cs-fixer and get flag of correction
"${cmd}" -q fix "${staged}" "${root}/bin/php-cs-fixer" -q fix "${staged}"
# if php-cs-fixer fix works, it returns 0 # if php-cs-fixer fix works, it returns 0
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
@ -21,4 +21,9 @@ for staged in ${staged_files}; do
fi fi
done done
exit 0 # do commit echo "Running php-doc-checker"
"${root}/bin/php-doc-check" src plugins components
# Only commit if there wasn't an error
exit $?