Created
November 30, 2012 15:38
-
-
Save bytespider/4176493 to your computer and use it in GitHub Desktop.
PHP pre-commit hook
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
ROOT_DIR=$(git rev-parse --show-toplevel); | |
PHP="php -l" | |
for file in $(git diff-index --name-only --diff-filter=ACM --cached HEAD -- | grep -e '\.(php|phtml)$'); do | |
$OUTPUT = $PHP $file 2>&1 | |
if $OUTPUT | grep 'No syntax errors detected'; then | |
exit 0 | |
else | |
echo $OUTPUT | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment