Skip to content

Commit

Permalink
Merge branch 'feature/limit-file-scope'
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegrunwell committed Nov 28, 2015
2 parents 109abfd + ea33c90 commit 3f39796
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ For a complete list of configuration options, see [the PHP CodeSniffer ruleset.x

## Adding to an Existing Project

Adding coding standards to an existing project can be a painful process. If the current codebase is a mess, making even standards cleanup commits becomes a giant hassle.
Adding coding standards to an existing project can be a painful process. WP Enforcer will only run the Git hook against changed files, but if the current codebase is a mess, making even standards cleanup commits becomes a giant hassle.

If you're adding WP Enforcer to a current project, it's recommended to follow the installation instructions above **in a new clean-up branch**, then remove the pre-commit hook:

Expand All @@ -70,3 +70,10 @@ $ ./vendor/bin/wp-enforcer
```

Finally, merge your clean-up branch into master, kicking your project's coding standards compliance into high gear.

## Changelog

### 0.2.0

* Restrict the Git hook to only changed files, not the entire codebase ([#1](https://github.com/stevegrunwell/wp-enforcer/issues/1)).
* Confirmed Windows Compatibility (as Git Bash ships with a version of Cygwin for all the Unix-y goodness needed). Props @EricMann ([#2](https://github.com/stevegrunwell/wp-enforcer/issues/2)).
10 changes: 9 additions & 1 deletion bin/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
#
# @package WP Enforcer

# Determine if we have a phpcs.xml file
if [[ -f ./phpcs.xml ]]; then
standard="--standard=./phpcs.xml"
else
standard=''
fi

# Run PHP CodeSniffer
echo "Running PHP CodeSniffer..."
./vendor/bin/phpcs

git diff --name-only --cached | xargs ./vendor/bin/phpcs $standard
if [ $? != 0 ]
then
echo "Please fix coding standards errors before committing"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stevegrunwell/wp-enforcer",
"description": "Git hooks to encourage well-written WordPress.",
"version": "0.1.0",
"version": "0.2.0",
"authors": [
{
"name": "Steve Grunwell",
Expand Down

0 comments on commit 3f39796

Please sign in to comment.