:hand: 一个可扩展的版本控制钩子框架。
This package is abandoned :rotating_light:.
See GrumPHP for a maintained alternative.
An extendable framework for version control hooks.
For a composer managed project you can simply run the following ...
$ composer require sjparkinson/static-reviewHooks can then be installed like so ...
$ vendor/bin/static-review.php hook:install vendor/sjparkinson/static-review/hooks/example-pre-commit.php .git/hooks/pre-commitOtherwise, if you don't use composer ...
$ git clone https://github.com/sjparkinson/static-review.git
$ cd static-review/
$ composer install --no-dev --optimize-autoloader
$ bin/static-review.php hook:install hooks/example-pre-commit.php ~/.../.git/hooks/pre-commitThe hooks can also be used for any project if you install static-review globally:
$ composer g require sjparkinson/static-reviewThen, just install the hooks as you would normally but reference the global installation path:
$ static-review.php hook:install ~/.composer/vendor/sjparkinson/static-review/hooks/static-review-commit-msg.php .git/hooks/commit-msgThis assumes you have set up global composer paths.
Static Review can be used for both files and commit message review. Below are basic hooks for each.
#!/usr/bin/env php
addReview(new LineEndingsReview());
$git = new GitVersionControl();
// Review the staged files.
$review->files($git->getStagedFiles());
// Check if any issues were found.
// Exit with a non-zero status to block the commit.
($reporter->hasIssues()) ? exit(1) : exit(0);#!/usr/bin/env php
addReview(new BodyLineLengthReview());
$git = new GitVersionControl();
// Review the current commit message.
// The hook is passed the file holding the commit message as the first argument.
$review->message($git->getCommitMessage($argv[1]));
// Check if any issues were found.
// Exit with a non-zero status to block the commit.
($reporter->hasIssues()) ? exit(1) : exit(0);…class WorkInProgressReview extends AbstractMessageReview
{
// Check if the commit message contains "wip"
public function review(ReporterInterface $reporter, ReviewableInterface $commit)
{
$fulltext = $commit->getSubject() . PHP_EOL . $commit->getBody();
if (preg_match('/\bwip\b/i', $fulltext)) {
$message = 'Do not commit WIP to shared branches';
$reporter->error($message, $this, $commit);
}
}
}See vagrantup.com and phpunit.de.
$ git clone https://github.com/sjparkinson/static-review.git
$ cd static-review/
$ vagrant up
$ vagrant ssh
...
$ cd /srv
$ composer update
$ composer testThe content of this library is released under the MIT License by Samuel Parkinson.
暂无开放 Issues,或尚未同步最近议题。