Git GitHub Lint
, (*1)
This project is designed to ensure that the commits you're making to a
repository follow the git coding style. This is the library component
with no web frontend., (*2)
The standard that they test for is the one described by Chris Beams., (*3)
The validations it implements are:, (*4)
- 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:, (*5)
Installing
composer require PurpleBooth/git-github-lint
Usage
You can try out this library by using it as a tool. You'll need to
generate a token on the GitHub Personal Access Token Page., (*6)
Usage
Billies-MacBook-Pro-2:git-github-lint billie$ bin/git-github-lint help git-github-lint:pr
Usage:
git-github-lint:pr [options] [--] <github-username> <github-repository> <pull-request-id>
Arguments:
github-username GitHub Username
github-repository GitHub Repository
pull-request-id The ID of the pull request
Options:
-t, --token=TOKEN The token to authenticate to the API with.
-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:
Evaluates a the commits in a pull request and checks that their messages match the style advised by Git. It will then update the "status" in github (that little dot next to the commits).
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
$ php vendor/bin/git-github-lint git-github-lint:pr \
-t my-token \
PurpleBooth \
git-github-lint \
3
git-github-lint:pr
==================
// Analysing PR PurpleBooth/git-github-lint#3
[OK] Finished!
You can look at the pull requests on this repo to see what the effect
is like in person., (*7)
Library
You can use the whole library, (*8)
<?php
$gitHubClient = new \Github\Client()
/** @var GitHubLint $gitHubLint **/
$gitHubLint = new GitHubLintImplementation($gitHubClient);
$gitHubLint->analyse('PurpleBooth', 'git-github-lint', 3);
// -> The commits on your PR should now be updated with a status
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., (*9)
Running the tests
To run the tests for coding style, (*10)
First checkout the library, then run, (*11)
composer install
Coding Style
We follow PSR2, and also enforce PHPDocs on all functions, (*12)
vendor/bin/phpcs -p --standard=psr2 src/ spec/
Unit tests
We use PHPSpec for unit tests, (*13)
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., (*14)
Versioning
We use SemVer for versioning. For the versions
available, see the tags on this repository., (*15)
Authors
See the list of contributors who participated in this project., (*16)
License
This project is licensed under the MIT License - see the LICENSE.md file for details, (*17)