Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/conventional-changelog-archived-repos/validate-commit-msg
DEPRECATED. Use https://github.com/marionebl/commitlint instead. githook to validate commit messages are up to standard
https://github.com/conventional-changelog-archived-repos/validate-commit-msg
Last synced: 7 days ago
JSON representation
DEPRECATED. Use https://github.com/marionebl/commitlint instead. githook to validate commit messages are up to standard
- Host: GitHub
- URL: https://github.com/conventional-changelog-archived-repos/validate-commit-msg
- Owner: conventional-changelog-archived-repos
- License: mit
- Archived: true
- Created: 2015-09-04T21:47:53.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-10T18:56:55.000Z (over 7 years ago)
- Last Synced: 2024-10-29T21:50:42.644Z (13 days ago)
- Language: JavaScript
- Homepage: http://conventionalcommits.org/
- Size: 144 KB
- Stars: 557
- Watchers: 8
- Forks: 100
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# validate-commit-msg
[![Build Status][build-badge]][build]
[![Code Coverage][coverage-badge]][coverage]
[![Dependencies][dependencyci-badge]][dependencyci]
[![version][version-badge]][package]
[![downloads][downloads-badge]][npm-stat]
[![MIT License][license-badge]][LICENSE][![All Contributors](https://img.shields.io/badge/all_contributors-28-orange.svg?style=flat-square)](#contributors)
[![PRs Welcome][prs-badge]][prs]
[![Donate][donate-badge]][donate]
[![Code of Conduct][coc-badge]][coc][![Watch on GitHub][github-watch-badge]][github-watch]
[![Star on GitHub][github-star-badge]][github-star]
[![Tweet][twitter-badge]][twitter]This provides you a binary that you can use as a githook to validate the commit message. I recommend
[husky](http://npm.im/husky). You'll want to make this part of the `commit-msg` githook, e.g. when using [husky](http://npm.im/husky), add `"commitmsg": "validate-commit-msg"` to your [npm scripts](https://docs.npmjs.com/misc/scripts) in `package.json`.Validates that your commit message follows this format:
```
():
```Or without optional scope:
```
:
```## Installation
This module is distributed via [npm](https://www.npmjs.com/) which is bundled with [node](https://nodejs.org/) and
should be installed as one of your project's `devDependencies`:```
npm install --save-dev validate-commit-msg
```## Usage
### options
You can specify options in `.vcmrc`.
It must be valid JSON file.
The default configuration object is:```json
{
"types": ["feat", "fix", "docs", "style", "refactor", "perf", "test", "build", "ci", "chore", "revert"],
"scope": {
"required": false,
"allowed": ["*"],
"validate": false,
"multiple": false
},
"warnOnFail": false,
"maxSubjectLength": 100,
"subjectPattern": ".+",
"subjectPatternErrorMsg": "subject does not match subject pattern!",
"helpMessage": "",
"autoFix": false
}
```Alternatively, options can be specified in `package.json`:
```json
{
"config": {
"validate-commit-msg": {
/* your config here */
}
}
}
````.vcmrc` has precedence, if it does not exist, then `package.json` will be used.
#### types
These are the types that are allowed for your commit message. If omitted, the value is what is shown above.
You can also specify: `"types": "*"` to indicate that you don't wish to validate types.
Or you can specify the name of a module that exports types according to the
[conventional-commit-types](https://github.com/commitizen/conventional-commit-types)
spec, e.g. `"types": "conventional-commit-types"`.#### scope
This object defines scope requirements for the commit message. Possible properties are:
##### required
A boolean to define whether a scope is required for all commit messages.
##### allowed
An array of scopes that are allowed for your commit message.
You may also define it as `"*"` which is the default to allow any scope names.
##### validate
A boolean to define whether or not to validate the scope(s) provided.
##### multiple
A boolean to define whether or not to allow multiple scopes.
#### warnOnFail
If this is set to `true` errors will be logged to the console, however the commit will still pass.
#### maxSubjectLength
This will control the maximum length of the subject.
#### subjectPattern
Optional, accepts a RegExp to match the commit message subject against.
#### subjectPatternErrorMsg
If `subjectPattern` is provided, this message will be displayed if the commit message subject does not match the pattern.
#### helpMessage
If provided, the helpMessage string is displayed when a commit message is not valid. This allows projects to provide a better developer experience for new contributors.
The `helpMessage` also supports interpolating a single `%s` with the original commit message.
#### autoFix
If this is set to `true`, type will be auto fixed to all lowercase, subject first letter will be lowercased, and the commit will pass (assuming there's nothing else wrong with it).
### Node
Through node you can use as follows
```javascript
var validateMessage = require('validate-commit-msg');var valid = validateMessage('chore(index): an example commit message');
// valid = true
```### CI
You can use your CI to validate your _last_ commit message:
```
validate-commit-msg "$(git log -1 --pretty=%B)"
```_Note_ this will only validate the last commit message, not all messages in a pull request.
### Monorepo
If your lerna repo looks something like this:
```
my-lerna-repo/
package.json
packages/
package-1/
package.json
package-2/
package.json
```The scope of your commit message should be one (or more) of the packages:
EG:
```json
{
"config": {
"validate-commit-msg": {
"scope": {
"required": true,
"allowed": ["package-1", "package-2"],
"validate": true,
"multiple": true
},
}
}
}
```### Other notes
If the commit message begins with `WIP` then none of the validation will happen.
## Credits
This was originally developed by contributors to [the angular.js project](https://github.com/angular/angular.js). I
pulled it out so I could re-use this same kind of thing in other projects.[build-badge]: https://img.shields.io/travis/kentcdodds/validate-commit-msg.svg?style=flat-square
[build]: https://travis-ci.org/kentcdodds/validate-commit-msg
[coverage-badge]: https://img.shields.io/codecov/c/github/kentcdodds/validate-commit-msg.svg?style=flat-square
[coverage]: https://codecov.io/github/kentcdodds/validate-commit-msg
[dependencyci-badge]: https://dependencyci.com/github/kentcdodds/validate-commit-msg/badge?style=flat-square
[dependencyci]: https://dependencyci.com/github/kentcdodds/validate-commit-msg
[version-badge]: https://img.shields.io/npm/v/validate-commit-msg.svg?style=flat-square
[package]: https://www.npmjs.com/package/validate-commit-msg
[downloads-badge]: https://img.shields.io/npm/dm/validate-commit-msg.svg?style=flat-square
[npm-stat]: http://npm-stat.com/charts.html?package=validate-commit-msg&from=2016-04-01
[license-badge]: https://img.shields.io/npm/l/validate-commit-msg.svg?style=flat-square
[license]: https://github.com/kentcdodds/validate-commit-msg/blob/master/LICENSE
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs]: http://makeapullrequest.com
[donate-badge]: https://img.shields.io/badge/$-support-green.svg?style=flat-square
[donate]: http://kcd.im/donate
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
[coc]: https://github.com/kentcdodds/validate-commit-msg/blob/master/CODE_OF_CONDUCT.md
[github-watch-badge]: https://img.shields.io/github/watchers/kentcdodds/validate-commit-msg.svg?style=social
[github-watch]: https://github.com/kentcdodds/validate-commit-msg/watchers
[github-star-badge]: https://img.shields.io/github/stars/kentcdodds/validate-commit-msg.svg?style=social
[github-star]: https://github.com/kentcdodds/validate-commit-msg/stargazers
[twitter]: https://twitter.com/intent/tweet?text=Check%20out%20validate-commit-msg!%20https://github.com/kentcdodds/validate-commit-msg%20%F0%9F%91%8D
[twitter-badge]: https://img.shields.io/twitter/url/https/github.com/kentcdodds/validate-commit-msg.svg?style=social## Contributors
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
| [
Kent C. Dodds](https://kentcdodds.com)
π [π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=kentcdodds) [π](https://github.com/kentcdodds/validate-commit-msg/commits?author=kentcdodds) π [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=kentcdodds) | [
Remy Sharp](http://remysharp.com)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=remy) [π](https://github.com/kentcdodds/validate-commit-msg/commits?author=remy) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=remy) | [
CΓ©dric Malard](http://valdun.net)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=cmalard) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=cmalard) | [
Mark Dalgleish](http://markdalgleish.com)
[π](https://github.com/kentcdodds/validate-commit-msg/commits?author=markdalgleish) | [
Ryan Kimber](https://formhero.io)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=ryan-kimber) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=ryan-kimber) | [
Javier Collado](https://github.com/jcollado)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=jcollado) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=jcollado) | [
Jamis Charles](https://github.com/jamischarles)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=jamischarles) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=jamischarles) |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [
Shawn Erquhart](http://www.professant.com)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=erquhart) [π](https://github.com/kentcdodds/validate-commit-msg/commits?author=erquhart) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=erquhart) | [
Tushar Mathur](http://tusharm.com)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=tusharmath) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=tusharmath) | [
Jason Dreyzehner](https://twitter.com/bitjson)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=bitjson) [π](https://github.com/kentcdodds/validate-commit-msg/commits?author=bitjson) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=bitjson) | [
Abimbola Idowu](http://twitter.com/hisabimbola)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=hisabimbola) | [
Gleb Bahmutov](https://glebbahmutov.com/)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=bahmutov) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=bahmutov) | [
Dennis](http://dennis.io)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=ds82) | [
Matt Lewis](https://mattlewis.me/)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=mattlewis92) |
| [
Tom Vincent](https://tlvince.com)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=tlvince) | [
Anders D. Johnson](https://andrz.me/)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=AndersDJohnson) [π](https://github.com/kentcdodds/validate-commit-msg/commits?author=AndersDJohnson) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=AndersDJohnson) | [
James Zetlen](http://jameszetlen.com)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=zetlen) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=zetlen) | [
Paul Bienkowski](http://opatut.de)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=opatut) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=opatut) | [
Barney Scott](https://github.com/bmds)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=bmds) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=bmds) | [
Emmanuel Murillo SΓ‘nchez](https://github.com/Emmurillo)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=Emmurillo) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=Emmurillo) | [
Hans Kristian Flaatten](https://starefossen.github.io)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=Starefossen) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=Starefossen) |
| [
Bo Lingen](https://github.com/citycide)
[π](https://github.com/kentcdodds/validate-commit-msg/commits?author=citycide) | [
Spyros Ioakeimidis](http://www.spyros.io)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=spirosikmd) [π](https://github.com/kentcdodds/validate-commit-msg/commits?author=spirosikmd) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=spirosikmd) | [
Matt Travi](https://matt.travi.org)
[π](https://github.com/kentcdodds/validate-commit-msg/issues?q=author%3Atravi) | [
Jonathan Garbee](http://jonathan.garbee.me)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=Garbee) [π](https://github.com/kentcdodds/validate-commit-msg/commits?author=Garbee) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=Garbee) | [
Tobias Lins](https://lins.in)
[π](https://github.com/kentcdodds/validate-commit-msg/commits?author=tobiaslins) | [
Max Claus Nunes](http://maxcnunes.com/)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=maxcnunes) | [
standy](https://github.com/standy)
[π»](https://github.com/kentcdodds/validate-commit-msg/commits?author=standy) [β οΈ](https://github.com/kentcdodds/validate-commit-msg/commits?author=standy) |This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!