Add coding standards check to sample git pre-push hook

pull/5084/head
Marco Villegas 2 years ago
parent 0a5c3b3022
commit c77e4159f3
  1. 13
      tests/scripts/git-hooks/pre-push

@ -23,6 +23,7 @@ remote="$1"
url="$2" url="$2"
z40=0000000000000000000000000000000000000000 z40=0000000000000000000000000000000000000000
composer=${composer-'composer'}
while read local_ref local_sha remote_ref remote_sha while read local_ref local_sha remote_ref remote_sha
do do
@ -47,6 +48,18 @@ do
echo >&2 "Found WIP commit in $local_ref, not pushing" echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1 exit 1
fi fi
# Run coding standards check over modified files.
modified_files=`git diff --diff-filter=d --name-only "$range"`
if [ -n "$modified_files" ]
then
$composer phpcs $modified_files
if [ $? -ne 0 ]
then
echo >&2 "A coding standards regressions was introduced, please fix it before pushing."
exit 1
fi
fi
fi fi
done done

Loading…
Cancel
Save