CmHook is GIT commit hook the code validator for PHP (Code Sniffer), CSS (base only), JS (JsHint) code and commit message formatter/filler with the issue tracker integration (JIRA, GitHub).
The main purpose of this project is
Supported file types: php, phtml, js, coffee, css, scss, xml, sh, scss, css, json, less, html, htm.
Target commit message:
Implemented #33: Make smth good now
- Added my file.
This commit message will be generated automatically, we need to type only commit description:
$ git add myfile.php
$ git commit -m 'Added my file.'
See more details about short commit messages.
v2.0.0-beta.47
To get last beta version please define your minimum-stability
.
{
"minimum-stability": "beta",
"prefer-stable": true
}
Due to reason the package requires one package which still in "dev", please fetch it first:
$ composer global require chobie/jira-api-restclient ^2.0@dev
Now fetch the package:
$ composer global require andkirby/commithook ~2.0@beta
If a project already have base configuration files all what you need to:
$ commithook config --xpath code/interpreter/php d:/s/php-7.0.14/php.exe --project-self
(You may try to use PHP Windows Binaries Downloader (gist))
$ composer global require squizlabs/php_codesniffer:~2.0@stable
$ commithook install
$ commithook tracker:wizard
.bashrc
Here is an example of .bashrc
file for global using.
If global way doesn't work you may use installation via create-project
.
Initialize configuration wizard
GIT integration: hook files installation
Ignore validation
Protect code
Enable JsHint validation (Javascript)
Commit message format
Ignore commit message validation
Active task in commit message
Auto-explode commit message into the list
The code validation works with GIT but it doesn't support git cache. It means if you added a file (git add file.php
), changed it, and trying to commit (without adding it into GIT cache). In commit, of course, you will get code from cache but validators will validate your real file. (#113)
You may quickly find gaps/trailing spaces in your code by the regular expression:
(\n\s*\n\s*\})|(\n\s*\n\s*\n)|(\{\n\s*\n)| +\n
Just use it in your IDE.
Tested on Windows in GIT Bash v2.9.
Feel free to create your faced issue.