https://github.com/jonallured/danger-commit_lint
Use Danger to lint your commit messages
https://github.com/jonallured/danger-commit_lint
Last synced: 11 days ago
JSON representation
Use Danger to lint your commit messages
- Host: GitHub
- URL: https://github.com/jonallured/danger-commit_lint
- Owner: jonallured
- License: mit
- Archived: true
- Created: 2016-08-25T16:13:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-08-16T15:10:40.000Z (over 3 years ago)
- Last Synced: 2024-10-06T00:19:55.644Z (7 months ago)
- Language: Ruby
- Size: 69.3 KB
- Stars: 32
- Watchers: 3
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-danger - danger-commit_lint - Use Danger to lint your commit messages. (Plugins / Ruby (danger))
README
# Commit Lint for Danger
[](https://travis-ci.org/jonallured/danger-commit_lint)
This is a [Danger Plugin][danger] that ensures nice and tidy commit messages.
The checks performed on each commit message are inspired by [Tim Pope's blog
post][tpope] on good commit messages, echoed by [git's own documentation][book]
on the subject.[danger]: http://danger.systems/plugins/commit_lint.html
[tpope]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
[book]: https://www.git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#Commit-Guidelines## Installation
```
$ gem install danger-commit_lint
```## Usage
Simply add this to your Dangerfile:
```ruby
commit_lint.check
```That will check each commit in the PR to ensure the following is true:
* Commit subject begins with a capital letter (`subject_cap`)
* Commit subject is more than one word (`subject_words`)
* Commit subject is no longer than 50 characters (`subject_length`)
* Commit subject does not end in a period (`subject_period`)
* Commit subject and body are separated by an empty line (`empty_line`)By default, Commit Lint fails, but you can configure this behavior.
## Configuration
Configuring Commit Lint is done by passing a hash. The four keys that can be
passed are:* `disable`
* `fail`
* `warn`
* `limit`The first three of these keys can accept either the symbol `:all` or an array of
checks. Here are some ways you could configure Commit Lint:```ruby
# warn on all checks (instead of failing)
commit_lint.check warn: :all# disable the `subject_period` check
commit_lint.check disable: [:subject_period]
```Remember, by default all checks are run and they will fail. Think of this as the
default:```ruby
commit_lint.check fail: :all
```Also note that there is one more way that Commit Lint can behave:
```ruby
commit_lint.check disable: :all
```This will actually throw a warning that Commit Lint isn't doing anything.
### Limiting number of commits checked
The `limit` key allows you to limit checks to the first `n` commits (oldest to
newest). This can be useful for PR workflows when squashing before merge where
you want the initial commit message to be linted, but want to exclude additional
commits pushed in response to change requests during a code review.```ruby
# limit checks to only the first (oldest) commit
commit_lint.check limit: 1
```