Skip to content

Instantly share code, notes, and snippets.

@terrillo
Last active March 10, 2017 16:19
Show Gist options
  • Save terrillo/b9c339033c84af5e2ba3af100733aafb to your computer and use it in GitHub Desktop.
Save terrillo/b9c339033c84af5e2ba3af100733aafb to your computer and use it in GitHub Desktop.
pre-commit
#!/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