From 1d6d20aacbacf28a471ff4f69de52ceca078be71 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Fri, 16 Apr 2021 15:52:47 +0000 Subject: [PATCH] [TOOLS] In pre-commit hook, only run php-doc-check if some PHP file changed --- bin/pre-commit | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/pre-commit b/bin/pre-commit index 833749ce9a..4b240bbfda 100755 --- a/bin/pre-commit +++ b/bin/pre-commit @@ -12,10 +12,7 @@ for staged in ${staged_files}; do if [ -f "${staged}" ] && [[ "${staged}" = *.php ]] then # use php-cs-fixer and get flag of correction - "${root}/bin/php-cs-fixer" -q fix "${staged}" - - # if php-cs-fixer fix works, it returns 0 - if [ "$?" -eq 0 ] + if "${root}/bin/php-cs-fixer" -q fix "${staged}" then git add "${staged}" # execute git add directly fi @@ -24,7 +21,9 @@ done echo "Running php-doc-checker" -"${root}/bin/php-doc-check" src plugins components +if echo "${staged_files}" | grep -F ".php"; then + "${root}/bin/php-doc-check" src plugins components +fi # Only commit if there wasn't an error exit $?