Skip to content

Commit

Permalink
Add pre-commit hook for contributors
Browse files Browse the repository at this point in the history
Making it easier for our contributors (and ourselves) to run the codesniffer
and avoid having to comment about coding standards in PRs.
  • Loading branch information
jadb committed Mar 30, 2015
1 parent db34583 commit b237f5f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions contrib/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
FILES=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`

# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
'
SFILES="$1"
IFS=$oIFS
fi
SFILES=${SFILES:-$FILES}

if [ "$FILES" != "" ]
then
echo "Running PHPCS"
./vendor/bin/phpcs --standard=vendor/cakephp/cakephp-codesniffer/CakePHP $SFILES
if [ $? != 0 ]
then
echo "PHPCS Errors found; commit aborted."
exit 1
fi
fi
exit $?

0 comments on commit b237f5f

Please sign in to comment.