Created
March 3, 2015 21:41
-
-
Save johnblackmore/75922efe40b0c328f6c2 to your computer and use it in GitHub Desktop.
PHP linting pre-commit hook (save to .git/hooks/pre-commit)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git diff --cached --name-status --diff-filter=ACMR | while read STATUS FILE; do | |
if [[ "$FILE" =~ ^.+(php|inc)$ ]]; then | |
php -l "$FILE" 1> /dev/null | |
if [ $? -ne 0 ]; then | |
echo "Abort! Files failed syntax check" >&2 | |
exit 1 | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment