Last active
December 14, 2015 21:18
-
-
Save rumkin/5150026 to your computer and use it in GitHub Desktop.
PHP syntax check on 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 | |
if [ ! -z $(tput colors) ]; then | |
bold=`tput bold` | |
normal=`tput sgr0` | |
fi | |
# Git info | |
commit=$(git log --max-count=1| head -n 1|cut -f 2 -d ' '); | |
status=0 | |
for file in $(git diff-tree --no-commit-id --name-only -r $commit); do | |
php=$(echo $file | egrep "\.php$") | |
if [ -z $php ]; then continue; fi | |
error=$(php -l $file 2>&1 >/dev/null) | |
if [ ! -z "$error" ]; then | |
status=1 | |
echo "${bold}${file}${normal}:" >&2 | |
echo "$error" >&2 | |
fi | |
done | |
exit $status |
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 | |
set -e | |
bin/phpsyntax |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment