Last active
March 10, 2017 16:19
-
-
Save terrillo/b9c339033c84af5e2ba3af100733aafb to your computer and use it in GitHub Desktop.
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/sh | |
FILES=`git diff --cached --name-only -- '*.php' '*.inc' '*.module'`; | |
if [ "$FILES" != "" ] | |
then | |
echo "Running Code Sniffer..." | |
command_result=`phpcs --standard=~/bm-core/docroot/sites/ruleset.xml --extensions=php,inc,module --encoding=utf-8 -n -p $FILES` | |
if [[ $command_result =~ ERROR ]] | |
then | |
echo "$command_result" | |
exit 1 | |
fi | |
if [ $? != 0 ] | |
then | |
git add $FILES | |
echo "Files Added" | |
fi | |
fi | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment