Skip to content

Latest commit

 

History

History
76 lines (57 loc) · 3.41 KB

docs.md

File metadata and controls

76 lines (57 loc) · 3.41 KB

git-commit-msg-linter

How it works

After installed, it will copy the executable file {PROJECT_ROOT}/.git/hooks/commit-msg if it exists to {PROJECT_ROOT}/.git/hooks/commit-msg.old then the commit-msg will be overwritten by our linting rules.

Before uninstalling, the commit-msg file will be restored and the commit-msg.old will be removed.

defaults

The default types includes feat, fix, docs, style, refactor, test, chore, perf, ci and temp.

The default max-len is 100 which means the commit message cannot be longer than 100 characters.

commitlinterrc.json

Except for default types, you can add, overwrite or forbid certain types and so does the max-len.

For example if you have this commitlinterrc.json file below in the root directory of your project:

{
  "types": {
    "feat": "ユーザーが知覚できる新機能",
    "build": "ビルドシステムまたは外部の依存関係に影響する変更(スコープの例:gulp、broccoli、npm)",
    "deps": "依存関係を追加、アップグレード、削除",
    "temp": false,
    "chore": false
  },
  "max-len": 80,
  "debug": true
}

which means:

  • Modify existing type feat's description to "ユーザーが知覚できる新機能".
  • Add two new types: build and deps.
  • temp is not allowed.
  • chore is forbidden as build covers the same scope.
  • Maximum length of a commit message is adjusted to 80.
  • Display verbose information about the commit message.

FAQs

  1. Why not conventional-changelog/commitlint?

    • Configuration is relatively complex.

    • No description for type, unfriendly to commit newbies. Because every time your are wondering which type should I use, you must jump out of you commit context to seek documentation in the wild web.

    • To modify type description is also not supported. Unfriendly to non-english speakers. For example, all my team members are Japanese, isn't it more productive to change all the descriptions to Japanese?

    • To add more types is also impossible. This is unacceptable for project with different types already existed.

TODO

  • Existing rule can be overwritten and new ones can be added through commitlinterrc.json.
  • is-english-only should be configurable through commitlinterrc.json, default false.
  • max-len should be configurable through commitlinterrc.json, default 100.
  • First letter of subject must be a lowercase one.
  • subject must not end with dot.
  • Empty scope parenthesis not allowed.
  • scope parenthesis must be of English which means full-width ones are not allowed.
  • Keep a space between Chinese and English character.
  • Fix git merge commit not valid.
  • Enable showing verbose information for debugging.
  • Interactive correcting and suggestion.
  • No backup when commit-msg.old existed.
  • Display commit message on invalid error.

Reference guidelines

  1. Angular Commit Message Guidelines
  2. Angular.js Git Commit Guidelines
  3. Google AngularJS Git Commit Message Conventions