Last active
October 29, 2015 17:51
-
-
Save bbrothers/127c5454d9138dc9a930 to your computer and use it in GitHub Desktop.
This file contains hidden or 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-only | while read FILE; do | |
if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then | |
# Courtesy of swytsh from the comments below. | |
if [[ -f $FILE ]]; then | |
php -l "$FILE" 1> /dev/null | |
if [ $? -ne 0 ]; then | |
echo -e "\e[1;31m\tAborting commit due to files with syntax errors" >&2 | |
exit 1 | |
fi | |
fi | |
fi | |
done || exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment