From 9f7ff7efbc20a43bb5890c645a1981df879bd94f Mon Sep 17 00:00:00 2001 From: Lee Willis Date: Mon, 30 Nov 2015 21:15:50 +0000 Subject: [PATCH 01/23] Use explicit path to phpcs. Makes sure that we use the local install of phpcs, which should also ensure that we use the local installed copy of the standards. Fixes #11. --- bin/hooks/pre-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/hooks/pre-commit b/bin/hooks/pre-commit index c54ce04..39eda8a 100644 --- a/bin/hooks/pre-commit +++ b/bin/hooks/pre-commit @@ -14,7 +14,7 @@ fi # Run PHP CodeSniffer echo "Running PHP CodeSniffer..." -git diff --name-only --cached | xargs phpcs $standard +git diff --name-only --cached | xargs vendor/bin/phpcs $standard if [ $? != 0 ] then echo "Please fix coding standards errors before committing" From a54986f153763d1a895a0667ccaa07cee71d194a Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Mon, 30 Nov 2015 17:41:37 -0500 Subject: [PATCH 02/23] Start the 0.4.0 changelog --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index c55115d..b86c095 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,10 @@ Finally, merge your clean-up branch into master, kicking your project's coding s ## Changelog +### 0.4.0 + +* Restore explicit reference to `vendor/bin` (previously removed in [#3](https://github.com/stevegrunwell/wp-enforcer/issues/3)) within the pre-commit Git hook ([#11](https://github.com/stevegrunwell/wp-enforcer/issues/11)). Props @leewillis77. + ### 0.3.0 - November 29, 2015 * Remove explicit references to `./vendor/bin/`, as Composer automatically prepends this directory to the user's path ([#3](https://github.com/stevegrunwell/wp-enforcer/issues/3)). Props @johnpbloch, @bswatson. From d69f584299542df2d48c4910e43b01ba4c43d062 Mon Sep 17 00:00:00 2001 From: Dave Ross Date: Mon, 30 Nov 2015 22:43:00 -0500 Subject: [PATCH 03/23] First stab at a --vip command line switch --- bin/wp-enforcer | 14 ++++++++++++-- phpcs-vip.xml.sample | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 phpcs-vip.xml.sample diff --git a/bin/wp-enforcer b/bin/wp-enforcer index 0f9ca99..0401e96 100755 --- a/bin/wp-enforcer +++ b/bin/wp-enforcer @@ -5,12 +5,13 @@ readonly BIN="$(cd "$(dirname "$0")" && pwd -P)" readonly DIR="$BIN/$(dirname "$(readlink "$0")")" readonly PROJECT="$(pwd)" +vip=false # Define command-line options here. # Follow -o with a comma-separated list of single-character option names. # Follow -l with a comma-separated list of long option names. # Options may be followed by one colon to indicate they have a required argument -if ! options=$(getopt -o h -l help -- "$@") +if ! options=$(getopt -o h,v -l help,vip -- "$@") then # something went wrong, getopt will put out an error message for us exit 1 @@ -24,7 +25,11 @@ do echo "After adding wp-enforcer to a project with Composer, run this script to finish installation."; echo ""; echo " -h, --help display this help and exit"; + echo " -v, --vip install phpcs ruleset for wordpress.com vip"; exit;; + -v|--vip) + vip=true; + break;; # For options with required arguments, an additional shift is required # -o|--option) myarg="$2" ; shift;; (--) shift; break;; @@ -96,7 +101,12 @@ fi # Copy the PHP CodeSniffer standards file if [[ ! -f "$PROJECT"/phpcs.xml ]]; then - cp "$DIR"/../phpcs.xml.sample "$PROJECT"/phpcs.xml + if [ "$vip" = false ]; then + sample_file_name="phpcs.xml.sample" + else + sample_file_name="phpcs-vip.xml.sample" + fi + cp "$DIR"/../"$sample_file_name" "$PROJECT"/phpcs.xml echo "Created sample phpcs.xml file" fi diff --git a/phpcs-vip.xml.sample b/phpcs-vip.xml.sample new file mode 100644 index 0000000..a7bd959 --- /dev/null +++ b/phpcs-vip.xml.sample @@ -0,0 +1,16 @@ + + + + Coding standards from WP Enforcer. + + + + */tests/* + */vendor/* + + + + From 96f9307e96eb32ba274a0720ef23a7ee305134c6 Mon Sep 17 00:00:00 2001 From: Ahmad Awais Date: Tue, 1 Dec 2015 13:48:57 +0500 Subject: [PATCH 04/23] rm is a dangerous command One must inform the users :) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c55115d..2127d9b 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ If you're adding WP Enforcer to a current project, it's recommended to follow th ```bash $ rm .git/hooks/pre-commit ``` +Note: Use `rm` command with care, you can end up deleting your OS (yes it is that powerful). So, check your command multiple times before running the `rm` command. If you are like me, I'd recommend using [Trash CLI](https://github.com/sindresorhus/trash). This leaves you with a copy of PHP CodeSniffer, a phpcs.xml file, and the WordPress Coding Standards but removes the "don't commit improperly formatted code" restrictions. While still in your clean-up branch, work through the codebase and clean up coding standards, running PHP CodeSniffer manually as needed: From 444d99f178a5918faff61ad1907e20cde2b6cb4a Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 06:33:01 -0500 Subject: [PATCH 05/23] Clean up Ahmad's `rm` warning --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2127d9b..77458a9 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ If you're adding WP Enforcer to a current project, it's recommended to follow th ```bash $ rm .git/hooks/pre-commit ``` -Note: Use `rm` command with care, you can end up deleting your OS (yes it is that powerful). So, check your command multiple times before running the `rm` command. If you are like me, I'd recommend using [Trash CLI](https://github.com/sindresorhus/trash). +> **Reminder:** Use the `rm` command with care; double-check everything you're passing to it before you execute, as we'd hate to see you lose valuable repository information (or worse: your operating system). This leaves you with a copy of PHP CodeSniffer, a phpcs.xml file, and the WordPress Coding Standards but removes the "don't commit improperly formatted code" restrictions. While still in your clean-up branch, work through the codebase and clean up coding standards, running PHP CodeSniffer manually as needed: From 98132ab3f2724c9a191d44f45b26c10acd6c140f Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 07:08:33 -0500 Subject: [PATCH 06/23] Adjust formatting for the help/usage output --- bin/wp-enforcer | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/wp-enforcer b/bin/wp-enforcer index 0f9ca99..dcabb45 100755 --- a/bin/wp-enforcer +++ b/bin/wp-enforcer @@ -20,10 +20,13 @@ while [ $# -gt 0 ] do case $1 in -h|--help) - echo "Usage: wp-enforcer [OPTION]..."; - echo "After adding wp-enforcer to a project with Composer, run this script to finish installation."; - echo ""; - echo " -h, --help display this help and exit"; + echo "USAGE:" + echo " wp-enforcer [--help|-h]" + echo "" + echo "After adding WP Enforcer to a project with Composer, run this script to finish installation." + echo "" + echo "OPTIONS:" + echo " --help, -h Show this help and usage" exit;; # For options with required arguments, an additional shift is required # -o|--option) myarg="$2" ; shift;; From 607332315034967e3f5163d96e077d41eb152d23 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 07:18:02 -0500 Subject: [PATCH 07/23] Add a -v|--version option, additional formatting of --help output --- bin/wp-enforcer | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/wp-enforcer b/bin/wp-enforcer index dcabb45..e57dcff 100755 --- a/bin/wp-enforcer +++ b/bin/wp-enforcer @@ -2,6 +2,7 @@ # # Copy files for WP Enforcer into the project directory. +readonly VERSION="0.4.0" readonly BIN="$(cd "$(dirname "$0")" && pwd -P)" readonly DIR="$BIN/$(dirname "$(readlink "$0")")" readonly PROJECT="$(pwd)" @@ -10,7 +11,7 @@ readonly PROJECT="$(pwd)" # Follow -o with a comma-separated list of single-character option names. # Follow -l with a comma-separated list of long option names. # Options may be followed by one colon to indicate they have a required argument -if ! options=$(getopt -o h -l help -- "$@") +if ! options=$(getopt -o h,v -l help,version -- "$@") then # something went wrong, getopt will put out an error message for us exit 1 @@ -20,13 +21,18 @@ while [ $# -gt 0 ] do case $1 in -h|--help) - echo "USAGE:" - echo " wp-enforcer [--help|-h]" - echo "" echo "After adding WP Enforcer to a project with Composer, run this script to finish installation." echo "" + echo "USAGE:" + echo " wp-enforcer [options]" + echo "" echo "OPTIONS:" - echo " --help, -h Show this help and usage" + echo " --help, -h Show this help and usage" + echo " --version, -v Show the current version of WP Enforcer" + echo "" + exit;; + -v|--version) + echo "$VERSION" exit;; # For options with required arguments, an additional shift is required # -o|--option) myarg="$2" ; shift;; From da809efc6c11f8995a158e7bc8d54f9b46fb4cbc Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 07:18:47 -0500 Subject: [PATCH 08/23] In case we ever run the script on its own repo, make sure we don't commit the generated phpcs.xml file --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5657f6e..64888e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -vendor \ No newline at end of file +vendor +phpcs.xml \ No newline at end of file From e9c436592b9db303bbe6db8bd7e24426f98fcbf7 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 07:23:15 -0500 Subject: [PATCH 09/23] Add changelog entry for the --help and --version options --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 936db07..359ca31 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ Finally, merge your clean-up branch into master, kicking your project's coding s ### 0.4.0 * Restore explicit reference to `vendor/bin` (previously removed in [#3](https://github.com/stevegrunwell/wp-enforcer/issues/3)) within the pre-commit Git hook ([#11](https://github.com/stevegrunwell/wp-enforcer/issues/11)). Props @leewillis77. +* Added `--help` and `--version` options to the `wp-enforcer` command for easier usage (and setting us up for more fun options in the future, [#8](https://github.com/stevegrunwell/wp-enforcer/issues/8)). Props @daveross. ### 0.3.0 - November 29, 2015 From dd5470cc5a992a5e150ee05302e48fbbe355199d Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 08:07:45 -0500 Subject: [PATCH 10/23] Filter the list of files staged for commit down to those handled by PHP_CodeSniffer; refs #12 --- bin/hooks/pre-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/hooks/pre-commit b/bin/hooks/pre-commit index c54ce04..34f87ad 100644 --- a/bin/hooks/pre-commit +++ b/bin/hooks/pre-commit @@ -14,7 +14,7 @@ fi # Run PHP CodeSniffer echo "Running PHP CodeSniffer..." -git diff --name-only --cached | xargs phpcs $standard +git diff --name-only --cached | egrep '\.(php|inc|js|css)$' | xargs vendor/bin/phpcs $standard if [ $? != 0 ] then echo "Please fix coding standards errors before committing" From 79cb6d75a36e8945eb8d0596a5b275cfe85dfa49 Mon Sep 17 00:00:00 2001 From: Dave Ross Date: Tue, 1 Dec 2015 09:32:03 -0500 Subject: [PATCH 11/23] Removed -v option per @stevegrunwell. Conflicts with usual option for verbose or version. --- bin/wp-enforcer | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/wp-enforcer b/bin/wp-enforcer index 0401e96..11e1bee 100755 --- a/bin/wp-enforcer +++ b/bin/wp-enforcer @@ -11,7 +11,7 @@ vip=false # Follow -o with a comma-separated list of single-character option names. # Follow -l with a comma-separated list of long option names. # Options may be followed by one colon to indicate they have a required argument -if ! options=$(getopt -o h,v -l help,vip -- "$@") +if ! options=$(getopt -o h -l help,vip -- "$@") then # something went wrong, getopt will put out an error message for us exit 1 @@ -25,9 +25,9 @@ do echo "After adding wp-enforcer to a project with Composer, run this script to finish installation."; echo ""; echo " -h, --help display this help and exit"; - echo " -v, --vip install phpcs ruleset for wordpress.com vip"; + echo " --vip install phpcs ruleset for wordpress.com vip"; exit;; - -v|--vip) + --vip) vip=true; break;; # For options with required arguments, an additional shift is required From 19b62bda559dde4ca880b3bdca0396e4db411db1 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 14:05:47 -0500 Subject: [PATCH 12/23] Prevent PHP_CodeSniffer from complaining when it's explicitly passed a file that contains no code. Fixes #12 --- bin/hooks/pre-commit | 2 +- phpcs.xml.sample | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/hooks/pre-commit b/bin/hooks/pre-commit index 34f87ad..39eda8a 100644 --- a/bin/hooks/pre-commit +++ b/bin/hooks/pre-commit @@ -14,7 +14,7 @@ fi # Run PHP CodeSniffer echo "Running PHP CodeSniffer..." -git diff --name-only --cached | egrep '\.(php|inc|js|css)$' | xargs vendor/bin/phpcs $standard +git diff --name-only --cached | xargs vendor/bin/phpcs $standard if [ $? != 0 ] then echo "Please fix coding standards errors before committing" diff --git a/phpcs.xml.sample b/phpcs.xml.sample index 2368528..c91c239 100644 --- a/phpcs.xml.sample +++ b/phpcs.xml.sample @@ -1,7 +1,7 @@ Coding standards from WP Enforcer. @@ -11,6 +11,14 @@ */tests/* */vendor/* + + + 0 + + \ No newline at end of file From 00345b2df5d36fb6ef823604b4b0152a5c2193b0 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 14:17:40 -0500 Subject: [PATCH 13/23] Added #12 to the Changelog --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 359ca31..4f36323 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ Finally, merge your clean-up branch into master, kicking your project's coding s * Restore explicit reference to `vendor/bin` (previously removed in [#3](https://github.com/stevegrunwell/wp-enforcer/issues/3)) within the pre-commit Git hook ([#11](https://github.com/stevegrunwell/wp-enforcer/issues/11)). Props @leewillis77. * Added `--help` and `--version` options to the `wp-enforcer` command for easier usage (and setting us up for more fun options in the future, [#8](https://github.com/stevegrunwell/wp-enforcer/issues/8)). Props @daveross. +* Fixed major bug wherein PHP_CodeSniffer was complaining about files not containing any code ([#12](https://github.com/stevegrunwell/wp-enforcer/issues/12)). ### 0.3.0 - November 29, 2015 From bf02027d09e0003e7073c9bd425cc77a6a841ec6 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 19:08:21 -0500 Subject: [PATCH 14/23] Break the Change Log into a separate file, fixes #19 --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ README.md | 12 ------------ 2 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..648171d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,31 @@ +# Change Log + +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](http://semver.org/). + +## [0.4.0] - Unreleased + +* Restore explicit reference to `vendor/bin` (previously removed in [#3](https://github.com/stevegrunwell/wp-enforcer/issues/3)) within the pre-commit Git hook ([#11](https://github.com/stevegrunwell/wp-enforcer/issues/11)). Props @leewillis77. +* Added `--help` and `--version` options to the `wp-enforcer` command for easier usage (and setting us up for more fun options in the future, [#8](https://github.com/stevegrunwell/wp-enforcer/issues/8)). Props @daveross. +* Fixed major bug wherein PHP_CodeSniffer was complaining about files not containing any code ([#12](https://github.com/stevegrunwell/wp-enforcer/issues/12)). + + +## [0.3.0] - 2015-11-29 + +* Remove explicit references to `./vendor/bin/`, as Composer automatically prepends this directory to the user's path ([#3](https://github.com/stevegrunwell/wp-enforcer/issues/3)). Props @johnpbloch, @bswatson. +* Automatically create a `.git/hooks` directory if it doesn't already exist ([#5](https://github.com/stevegrunwell/wp-enforcer/issues/5)). + + +## [0.2.0] - 2015-11-27 + +* 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)). + + +## 0.1.0 - 2015-11-22 + +* Initial public release. + +[0.4.0]: https://github.com/stevegrunwell/wp-enforcer/compare/v0.3.0...HEAD +[0.3.0]: https://github.com/stevegrunwell/wp-enforcer/compare/v0.2.0...v0.3.0 +[0.2.0]: https://github.com/stevegrunwell/wp-enforcer/compare/v0.1.0...v0.2.0 \ No newline at end of file diff --git a/README.md b/README.md index c55115d..a6f30de 100644 --- a/README.md +++ b/README.md @@ -73,15 +73,3 @@ $ ./vendor/bin/wp-enforcer ``` Finally, merge your clean-up branch into master, kicking your project's coding standards compliance into high gear. - -## Changelog - -### 0.3.0 - November 29, 2015 - -* Remove explicit references to `./vendor/bin/`, as Composer automatically prepends this directory to the user's path ([#3](https://github.com/stevegrunwell/wp-enforcer/issues/3)). Props @johnpbloch, @bswatson. -* Automatically create a `.git/hooks` directory if it doesn't already exist ([#5](https://github.com/stevegrunwell/wp-enforcer/issues/5)). - -### 0.2.0 - November 27, 2015 - -* 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)). From 16caa708fd50098386c5cd8e14c5d42b27d49878 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 19:12:01 -0500 Subject: [PATCH 15/23] Move more links into the bottom of the markdown doc for easier readability --- CHANGELOG.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 648171d..a0ae914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,21 +5,21 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [0.4.0] - Unreleased -* Restore explicit reference to `vendor/bin` (previously removed in [#3](https://github.com/stevegrunwell/wp-enforcer/issues/3)) within the pre-commit Git hook ([#11](https://github.com/stevegrunwell/wp-enforcer/issues/11)). Props @leewillis77. -* Added `--help` and `--version` options to the `wp-enforcer` command for easier usage (and setting us up for more fun options in the future, [#8](https://github.com/stevegrunwell/wp-enforcer/issues/8)). Props @daveross. -* Fixed major bug wherein PHP_CodeSniffer was complaining about files not containing any code ([#12](https://github.com/stevegrunwell/wp-enforcer/issues/12)). +* Restore explicit reference to `vendor/bin` (previously removed in [#3]) within the pre-commit Git hook ([#11]). Props @leewillis77. +* Added `--help` and `--version` options to the `wp-enforcer` command for easier usage (and setting us up for more fun options in the future, [#8]). Props @daveross. +* Fixed major bug wherein PHP_CodeSniffer was complaining about files not containing any code ([#12]). ## [0.3.0] - 2015-11-29 -* Remove explicit references to `./vendor/bin/`, as Composer automatically prepends this directory to the user's path ([#3](https://github.com/stevegrunwell/wp-enforcer/issues/3)). Props @johnpbloch, @bswatson. -* Automatically create a `.git/hooks` directory if it doesn't already exist ([#5](https://github.com/stevegrunwell/wp-enforcer/issues/5)). +* Remove explicit references to `./vendor/bin/`, as Composer automatically prepends this directory to the user's path ([#3]). Props @johnpbloch, @bswatson. +* Automatically create a `.git/hooks` directory if it doesn't already exist ([#5]). ## [0.2.0] - 2015-11-27 -* 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)). +* Restrict the Git hook to only changed files, not the entire codebase ([#1]). +* Confirmed Windows Compatibility (as Git Bash ships with a version of Cygwin for all the Unix-y goodness needed). Props @EricMann ([#2]). ## 0.1.0 - 2015-11-22 @@ -28,4 +28,11 @@ This project adheres to [Semantic Versioning](http://semver.org/). [0.4.0]: https://github.com/stevegrunwell/wp-enforcer/compare/v0.3.0...HEAD [0.3.0]: https://github.com/stevegrunwell/wp-enforcer/compare/v0.2.0...v0.3.0 -[0.2.0]: https://github.com/stevegrunwell/wp-enforcer/compare/v0.1.0...v0.2.0 \ No newline at end of file +[0.2.0]: https://github.com/stevegrunwell/wp-enforcer/compare/v0.1.0...v0.2.0 +[#1]: https://github.com/stevegrunwell/wp-enforcer/issues/1 +[#2]: https://github.com/stevegrunwell/wp-enforcer/issues/2 +[#3]: https://github.com/stevegrunwell/wp-enforcer/issues/3 +[#5]: https://github.com/stevegrunwell/wp-enforcer/issues/5 +[#8]: https://github.com/stevegrunwell/wp-enforcer/issues/8 +[#11]: https://github.com/stevegrunwell/wp-enforcer/issues/11 +[#12]: https://github.com/stevegrunwell/wp-enforcer/issues/12 \ No newline at end of file From a0313b8427dfcb02a7823e32909859ab4b1b0a46 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 19:14:04 -0500 Subject: [PATCH 16/23] Add an entry to the change log about changes made to the change log. wow. much meta. --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0ae914..4fc3a1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Restore explicit reference to `vendor/bin` (previously removed in [#3]) within the pre-commit Git hook ([#11]). Props @leewillis77. * Added `--help` and `--version` options to the `wp-enforcer` command for easier usage (and setting us up for more fun options in the future, [#8]). Props @daveross. * Fixed major bug wherein PHP_CodeSniffer was complaining about files not containing any code ([#12]). +* Moved the Change Log out of the README and into CHANGELOG.md ([#19]). ## [0.3.0] - 2015-11-29 @@ -35,4 +36,5 @@ This project adheres to [Semantic Versioning](http://semver.org/). [#5]: https://github.com/stevegrunwell/wp-enforcer/issues/5 [#8]: https://github.com/stevegrunwell/wp-enforcer/issues/8 [#11]: https://github.com/stevegrunwell/wp-enforcer/issues/11 -[#12]: https://github.com/stevegrunwell/wp-enforcer/issues/12 \ No newline at end of file +[#12]: https://github.com/stevegrunwell/wp-enforcer/issues/12 +[#19]: https://github.com/stevegrunwell/wp-enforcer/issues/19 \ No newline at end of file From fc65769aa01fb129cd19917a02eab7d7d65703d1 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 20:08:51 -0500 Subject: [PATCH 17/23] Add documentation for the --vip flag to the README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 329cc40..c845f0e 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,16 @@ If you'd like to require WP Enforcer for all developers on your project, you can ] ``` +### Writing for WordPress.com VIP + +WP Enforcer includes built-in support for the [WordPress.com VIP coding standards](https://vip.wordpress.com/documentation/developers-guide-to-wordpress-com-vip/), simply add `--vip` when you run the `wp-enforcer` command (including in the post-install and post-update commands). + +If you need to switch an existing project to the WordPress.com VIP coding standards, you can add the following to your project's phpcs.xml file (replacing "WordPress-Extra", if it's set): + +```xml + +``` + ## Configuration From 5bba8d438778560e42337f37f2fe06986dd03b53 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 20:10:53 -0500 Subject: [PATCH 18/23] Adjust whitespace in self-closing XML tags; add the fix from #12 to the VIP sample file --- phpcs-vip.xml.sample | 12 ++++++++++-- phpcs.xml.sample | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/phpcs-vip.xml.sample b/phpcs-vip.xml.sample index a7bd959..2430add 100644 --- a/phpcs-vip.xml.sample +++ b/phpcs-vip.xml.sample @@ -11,6 +11,14 @@ */tests/* */vendor/* - - + + + 0 + + + + diff --git a/phpcs.xml.sample b/phpcs.xml.sample index c91c239..8c28a3b 100644 --- a/phpcs.xml.sample +++ b/phpcs.xml.sample @@ -19,6 +19,6 @@ 0 - - + + \ No newline at end of file From 39ec9a3bc36567f17dff1e69068dd6eaac88bb1d Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 20:20:04 -0500 Subject: [PATCH 19/23] Add Dave's --vip flag (#7) to the Change Log --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fc3a1a..915b00f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Restore explicit reference to `vendor/bin` (previously removed in [#3]) within the pre-commit Git hook ([#11]). Props @leewillis77. * Added `--help` and `--version` options to the `wp-enforcer` command for easier usage (and setting us up for more fun options in the future, [#8]). Props @daveross. * Fixed major bug wherein PHP_CodeSniffer was complaining about files not containing any code ([#12]). +* Added a `--vip` option to the `wp-enforcer` command to use WordPress.com VIP coding standards ([#7]). Props @daveross. * Moved the Change Log out of the README and into CHANGELOG.md ([#19]). @@ -34,6 +35,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). [#2]: https://github.com/stevegrunwell/wp-enforcer/issues/2 [#3]: https://github.com/stevegrunwell/wp-enforcer/issues/3 [#5]: https://github.com/stevegrunwell/wp-enforcer/issues/5 +[#7]: https://github.com/stevegrunwell/wp-enforcer/issues/7 [#8]: https://github.com/stevegrunwell/wp-enforcer/issues/8 [#11]: https://github.com/stevegrunwell/wp-enforcer/issues/11 [#12]: https://github.com/stevegrunwell/wp-enforcer/issues/12 From 6b3b567de299d54e45e42142da461fbdebb71287 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 21:04:25 -0500 Subject: [PATCH 20/23] Standardize the use of 'PHP_CodeSniffer' across the repo --- README.md | 10 +++++----- bin/hooks/pre-commit | 4 ++-- bin/wp-enforcer | 4 ++-- composer.json | 2 +- phpcs-vip.xml.sample | 2 +- phpcs.xml.sample | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c845f0e..ddfc689 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,12 @@ When writing for a platform as big as WordPress – especially in a team environment – a consistent set of coding standards is vital. Having multiple developers committing code using a mixture of spaces and tabs, inconsistent formatting, or otherwise varying coding styles can lead to headache-inducing merge conflicts. -There are a number of great tools available to check against established coding standards (namely [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)), but setting them up on a project can be a pain. WP Enforcer is designed to make this setup a breeze. +There are a number of great tools available to check against established coding standards (namely [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)), but setting them up on a project can be a pain. WP Enforcer is designed to make this setup a breeze. ## How does it work? -WP Enforcer uses [Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to automatically run PHP CodeSniffer every time a developer tries to make a commit; if the code isn't up-to-snuff, the commit will be rejected and the developer will get a message explaining what needs to be fixed. +WP Enforcer uses [Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to automatically run PHP_CodeSniffer every time a developer tries to make a commit; if the code isn't up-to-snuff, the commit will be rejected and the developer will get a message explaining what needs to be fixed. **Note:** If your project already has messy standards you may not want to make WP Enforcer mandatory until *after* you've cleaned up the codebase or suddenly commits will be quite painful! See [Adding to an Existing Project](#adding-to-an-existing-project) for an easy work-around. @@ -55,9 +55,9 @@ If you need to switch an existing project to the WordPress.com VIP coding standa ## Configuration -PHP CodeSniffer allows you to [define a custom, default ruleset by creating a phpcs.xml file in your project root](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). WP Enforcer will automatically create a phpcs.xml file in your project if one doesn't already exist, but you can edit this to exclude certain files/directories, ignore specific rules, or load additional rulesets. +PHP_CodeSniffer allows you to [define a custom, default ruleset by creating a phpcs.xml file in your project root](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). WP Enforcer will automatically create a phpcs.xml file in your project if one doesn't already exist, but you can edit this to exclude certain files/directories, ignore specific rules, or load additional rulesets. -For a complete list of configuration options, see [the PHP CodeSniffer ruleset.xml standard](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml). +For a complete list of configuration options, see [the PHP_CodeSniffer ruleset.xml standard](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml). ## Adding to an Existing Project @@ -71,7 +71,7 @@ $ rm .git/hooks/pre-commit ``` > **Reminder:** Use the `rm` command with care; double-check everything you're passing to it before you execute, as we'd hate to see you lose valuable repository information (or worse: your operating system). -This leaves you with a copy of PHP CodeSniffer, a phpcs.xml file, and the WordPress Coding Standards but removes the "don't commit improperly formatted code" restrictions. While still in your clean-up branch, work through the codebase and clean up coding standards, running PHP CodeSniffer manually as needed: +This leaves you with a copy of PHP_CodeSniffer, a phpcs.xml file, and the WordPress Coding Standards but removes the "don't commit improperly formatted code" restrictions. While still in your clean-up branch, work through the codebase and clean up coding standards, running PHP_CodeSniffer manually as needed: ```bash $ ./vendor/bin/phpcs diff --git a/bin/hooks/pre-commit b/bin/hooks/pre-commit index 39eda8a..cc6ca3a 100644 --- a/bin/hooks/pre-commit +++ b/bin/hooks/pre-commit @@ -11,8 +11,8 @@ else standard='' fi -# Run PHP CodeSniffer -echo "Running PHP CodeSniffer..." +# Run PHP_CodeSniffer +echo "Running PHP_CodeSniffer..." git diff --name-only --cached | xargs vendor/bin/phpcs $standard if [ $? != 0 ] diff --git a/bin/wp-enforcer b/bin/wp-enforcer index d412a95..b6e92ca 100755 --- a/bin/wp-enforcer +++ b/bin/wp-enforcer @@ -108,7 +108,7 @@ else copy_hook "pre-commit" fi -# Copy the PHP CodeSniffer standards file +# Copy the PHP_CodeSniffer standards file if [[ ! -f "$PROJECT"/phpcs.xml ]]; then if [ "$vip" = false ]; then sample_file_name="phpcs.xml.sample" @@ -119,7 +119,7 @@ if [[ ! -f "$PROJECT"/phpcs.xml ]]; then echo "Created sample phpcs.xml file" fi -# Configure PHP CodeSniffer +# Configure PHP_CodeSniffer installed_paths="$("$BIN"/phpcs --config-show | grep "installed_paths:")" if [[ "$installed_paths" != "installed_paths: ../../wp-coding-standards/wpcs" ]]; then "$BIN"/phpcs --config-set installed_paths ../../wp-coding-standards/wpcs diff --git a/composer.json b/composer.json index 0379b97..64dffea 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "git hooks", "WordPress", "coding standards", - "PHP CodeSniffer" + "PHP_CodeSniffer" ], "require": { "wp-coding-standards/wpcs": "0.8.0" diff --git a/phpcs-vip.xml.sample b/phpcs-vip.xml.sample index 2430add..6b2034f 100644 --- a/phpcs-vip.xml.sample +++ b/phpcs-vip.xml.sample @@ -1,6 +1,6 @@ diff --git a/phpcs.xml.sample b/phpcs.xml.sample index 8c28a3b..563f72e 100644 --- a/phpcs.xml.sample +++ b/phpcs.xml.sample @@ -1,6 +1,6 @@ From b850613e6ec68c7436b4166b3725b3454f618db4 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 21:16:27 -0500 Subject: [PATCH 21/23] Specify that WP Enforcer is now using the Gitflow workflow for branching --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 48dd2e3..2ccbdd2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,8 +5,8 @@ Thank you for taking an interest in helping enforce coding standards on WordPres This project is open for anyone to make suggestions, report issues, and contribute code, but please adhere to the following guidelines: 1. **Keep the code as portable as possible:!** Not everyone is running the same, super-cool setup that you use, so we're targeting code that will run across the largest number of machines. That means Bash scripting that will run on OSX, Linux, and Cygwin for our friends on Windows. -2. **The code is meant to be a starting point for PHP_CodeSniffer usage.** There are a lot of different configurations for WordPress projects, so the best thing we can do is give developers the tools they need to get started and point them to things like [the PHP_CodeSniffer ruleset.xml standard](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml) +2. **The code is meant to be a starting point for PHP_CodeSniffer usage.** There are a lot of different configurations for WordPress projects, so the best thing we can do is give developers the tools they need to get started and point them to things like [the PHP_CodeSniffer ruleset.xml standard](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml). ## Branching strategy -The **master** branch should be considered stable, enabling people to pull from "dev-master" at any time and be sure their projects are safe. Active development happens in the **develop** branch. +The **master** branch should be considered stable, enabling people to pull from "dev-master" at any time and be sure their projects are safe. Active development happens in the **develop** branch. New branches should fork off of the **develop** branch, as this repository is now following the [Gitflow Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) as of version 0.4.0. \ No newline at end of file From 26ff6aa17674bed4aa6485612b1350f912c1408b Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 1 Dec 2015 21:28:19 -0500 Subject: [PATCH 22/23] Remove a stray colon in the contributing doc --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ccbdd2..d139388 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Thank you for taking an interest in helping enforce coding standards on WordPres This project is open for anyone to make suggestions, report issues, and contribute code, but please adhere to the following guidelines: -1. **Keep the code as portable as possible:!** Not everyone is running the same, super-cool setup that you use, so we're targeting code that will run across the largest number of machines. That means Bash scripting that will run on OSX, Linux, and Cygwin for our friends on Windows. +1. **Keep the code as portable as possible!** Not everyone is running the same, super-cool setup that you use, so we're targeting code that will run across the largest number of machines. That means Bash scripting that will run on OSX, Linux, and Cygwin for our friends on Windows. 2. **The code is meant to be a starting point for PHP_CodeSniffer usage.** There are a lot of different configurations for WordPress projects, so the best thing we can do is give developers the tools they need to get started and point them to things like [the PHP_CodeSniffer ruleset.xml standard](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml). ## Branching strategy From 071c85f306e95729aaa98721163554f96635ba38 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Wed, 2 Dec 2015 13:28:23 -0500 Subject: [PATCH 23/23] Version bump of 0.4.0 --- CHANGELOG.md | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 915b00f..05d80f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [0.4.0] - Unreleased +## [0.4.0] - 2015-12-02 * Restore explicit reference to `vendor/bin` (previously removed in [#3]) within the pre-commit Git hook ([#11]). Props @leewillis77. * Added `--help` and `--version` options to the `wp-enforcer` command for easier usage (and setting us up for more fun options in the future, [#8]). Props @daveross. diff --git a/composer.json b/composer.json index 64dffea..b922a4c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "stevegrunwell/wp-enforcer", "description": "Git hooks to encourage well-written WordPress.", - "version": "0.3.0", + "version": "0.4.0", "authors": [ { "name": "Steve Grunwell",