2017 © Pedro Peláez
 

project git-lint-validators

Lint git commits

image

purplebooth/git-lint-validators

Lint git commits

  • Sunday, October 30, 2016
  • by PurpleBooth
  • Repository
  • 2 Watchers
  • 10 Stars
  • 751 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 3 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

This package is abandoned and no longer maintained. The author suggests using the sebastianfeldmann/captainhook package instead., (*1)

Git Lint

Scrutinizer Code Quality Build Status Dependency Status Latest Stable Version License, (*2)

This project is designed to ensure that the commits you're making to a repository follow the git coding style. This is simply the basic validators., (*3)

The standard that they test for is the one described by Chris Beams., (*4)

The validations it implements are:, (*5)

  • Separate subject from body with a blank line
  • Limit the subject line to 50 characters (soft limit, hard limit at 69)
  • Capitalize the subject line
  • Do not end the subject line with a period
  • Wrap the body at 72 characters

Getting Started

Prerequisities

You'll need to install:, (*6)

  • PHP (Minimum 7.0)

Installing

composer require --dev PurpleBooth/git-lint-validators

Usage

Tool

You can try out this library by using it as a git commit hook., (*7)

Git hook installation

Use the install-git-hook Composer script to install the hook. An existing hook is backed to .git/hooks/commit-msg.bak., (*8)

composer install-git-hook

It's fairly customisable too, here are some options:, (*9)

$ vendor/bin/git-lint-validators help git-lint-validator:hook
Usage:
  git-lint-validator:hook [options] [--] <commit-message-file>

Arguments:
  commit-message-file                Path to commit message file

Options:
  -i, --ignore[=IGNORE]              Ignore a commit message that matches this pattern and don't test it [default: ["/^Merge branch/"]] (multiple values allowed)
  -c, --comment-char[=COMMENT-CHAR]  Ignore lines that are prefixed with this character [default: "#"]
  -h, --help                         Display this help message
  -q, --quiet                        Do not output any message
  -V, --version                      Display this application version
      --ansi                         Force ANSI output
      --no-ansi                      Disable ANSI output
  -n, --no-interaction               Do not ask any interactive question
  -v|vv|vvv, --verbose               Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
 Check your commit messages to ensure they follow the guidelines described by Chris Beams.
 To enable the Git hook in your project run 'composer install-git-hook.'


 Here are some good articles on commit message style:

 * http://chris.beams.io/posts/git-commit/
 * https://git-scm.com/book/ch5-2.html#Commit-Guidelines
 * https://github.com/blog/926-shiny-new-commit-styles


Output While Running


$ git commit [ERROR] Incorrectly formatted commit message * Please limit the body line length of the commit message to 72 characters (http://chris.beams.io/posts/git-commit/#wrap-72) Your Commit Message ------------------- Add commit message to output of hook It can be frustrating if you've lost a large git commit message because it doesn't match the style guide. This will add a little message including your commit details # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch added-original-commit-message-to-hook # Changes to be committed: # modified: src/PurpleBooth/GitLintValidators/Command/Hook.php # [WARNING] A commit has not been created

Git commit message template installation

Use the install-git-commit-message-template Composer script to install and configure a commit message template following the rules of Chris Beams. The commit message template is written to .git/.gitmessage and will than be used when issuing a git commit w/o the message option., (*10)

composer install-git-commit-message-template

Library

You can use the whole library, (*11)

<?php

$validatorFactory = new ValidatorFactoryImplementation();
$validators       = $validatorFactory->getMessageValidator();

$message
    = <<<MESSAGE
This is an example title

This is a message body. This is another part of the body.
MESSAGE;

$exampleMessage = new MessageImplementation("exampleSha", $message);

$validators->validate($exampleMessage);
// -> Message Object will now have a Status objects set on them

Alternatively you could use the validators alone, (*12)

<?php

new ValidateMessageImplementation(
    [
        new CapitalizeTheSubjectLineValidator(),
        new DoNotEndTheSubjectLineWithAPeriodValidator(),
    ]
);

$message
    = <<<MESSAGE
This is an example title

This is a message body. This is another part of the body.
MESSAGE;

$exampleMessage = new MessageImplementation("exampleSha", $message);

$messageValidator->validate($exampleMessage);
// -> Message Object will now have a Status objects set on them

Please depend on the interfaces rather than the concrete implementations. Concrete implementations may change without causing a BC break, interfaces changing will cause major version increment, indicating a BC break., (*13)

Running the tests

First checkout the library, then run, (*14)

composer install

Coding Style

We follow PSR2, and also enforce PHPDocs on all functions. To run the tests for coding style violations, (*15)

vendor/bin/phpcs -p --standard=psr2 src/

Unit tests

We use PHPSpec for unit tests. To run the unit tests, (*16)

vendor/bin/phpspec run

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us., (*17)

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository., (*18)

Authors

See the list of contributors who participated in this project., (*19)

License

This project is licensed under the MIT License - see the LICENSE.md file for details., (*20)

The Versions

02/09 2016

v1.2.0

1.2.0.0

Lint git commits

  Sources   Download

MIT

The Requires

 

The Development Requires

by Billie Thompson

09/08 2016

v1.1.0

1.1.0.0

Lint git commits

  Sources   Download

MIT

The Requires

 

The Development Requires

by Billie Thompson

07/08 2016

v1.0.0

1.0.0.0

Lint github commits and update their status

  Sources   Download

MIT

The Requires

 

The Development Requires

by Billie Thompson

07/08 2016

v0.1.0

0.1.0.0

Lint github commits and update their status

  Sources   Download

MIT

The Requires

 

The Development Requires

by Billie Thompson