Skip to content

Commit

Permalink
Update pre-commit hook to look for staged php files
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Oct 7, 2013
1 parent 3ddac64 commit f5f2c1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ if [ -e .jshintrc ]; then
fi

# PHP_CodeSniffer WordPress Coding Standards
changed_php_files=$(git status --porcelain | egrep '^.[MARC]' | cut -c4- | egrep '.php$' | wc -l)
changed_php_files=$(git status --porcelain | egrep '^ ?[MARC]' | cut -c4- | egrep '.php$' | wc -l)
if [ $changed_php_files != 0 ]; then
if command -v jshint >/dev/null 2>&1; then
phpcs_standard=$(if [ -e ruleset.xml ]; then echo ruleset.xml; else echo WordPress; fi)
phpcs -p -s -v --standard=$phpcs_standard $(git status --porcelain | egrep '^.[MARC]' | cut -c4- | egrep '.php$')
phpcs -p -s -v --standard=$phpcs_standard $(git status --porcelain | egrep '^ ?[MARC]' | cut -c4- | egrep '.php$')
else
echo "Skipping phpcs since not installed"
fi
Expand Down

0 comments on commit f5f2c1c

Please sign in to comment.