Created
January 17, 2012 23:15
-
-
Save jjbohn/1629700 to your computer and use it in GitHub Desktop.
jjbohn 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
#!/bin/bash | |
diff=`git diff-index --name-status HEAD -- | cut -c3-` | |
echo "Checking for stray debugging code..." | |
for FILE in $diff ; do | |
if [[ -f $FILE && `egrep "(console.log)|(var_dump)|(print_r)" $FILE` ]]; then | |
echo $FILE 'contains debugging code. Commit canceled.' | |
exit 1 | |
fi | |
done | |
# Run unit tests | |
echo "Running all unit tests..." | |
phpunit -c opensky/ --exclude-group functional,integration,crashy | |
if [[ $? != 0 ]]; then | |
echo "Unit test(s) failed. Commit canceled." | |
exit 1 | |
fi | |
echo "Running changed tests..." | |
for FILE in $diff ; do | |
if [[ -f $FILE && ${FILE: -8} == "Test.php" ]]; then | |
phpunit -c opensky/ $FILE | |
if [[ $? != 0 ]]; then | |
echo $FILE ' test(s) failed. Commit canceled.' | |
exit | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment