Skip to content

Commit 6162b1e

Browse files
committed
Test adding PHPCS check to the pre-push hook
1 parent b00031f commit 6162b1e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

.git-hooks-matomo/pre-push

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,29 @@ STATUS=0
6262

6363

6464

65+
# Ensure that PHPCS command is available
66+
PHPCS_COMMAND=""
67+
PHPCBF_COMMAND=""
68+
if [ -f "${MATOMO_DIR}/vendor/bin/phpcs" ]; then
69+
PHPCS_COMMAND="${MATOMO_DIR}/vendor/bin/phpcs"
70+
PHPCBF_COMMAND="${MATOMO_DIR}/vendor/bin/phpcbf ${REPO_DIR} --standard=${REPO_DIR}/phpcs.xml"
71+
fi
72+
# If no command, exit
73+
if [[ -z "PHPCS_COMMAND" ]]; then
74+
echo "No way to run phpcs found."
75+
exit 1
76+
fi
77+
78+
echo "Running PHPCS on repo: ${PHPCS_COMMAND} --report-full --standard=${REPO_DIR}/phpcs.xml ${REPO_DIR}"
79+
if ! $PHPCS_COMMAND --report-full --standard=${REPO_DIR}/phpcs.xml ${REPO_DIR}; then
80+
echo "There was an issue found during the PHPCS check."
81+
echo "You might try running PHPCBF to automatically fix issues before manually fixing them: ${PHPCBF_COMMAND}"
82+
echo ""
83+
STATUS=1
84+
fi
85+
86+
87+
6588
### Run PHPStan on newly created files. ###
6689

6790
PHPSTAN_CREATED_CONFIG=phpstan/phpstan.created.neon

0 commit comments

Comments
 (0)