|
| 1 | +## Git Commit Message Convention |
| 2 | + |
| 3 | +> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular). |
| 4 | +
|
| 5 | +Using conventional commit messages, we can automate the process of generating the CHANGELOG file. All commits messages will automatically be validated against the following regex. |
| 6 | + |
| 7 | +``` js |
| 8 | +/^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|ci|chore|types|build|improvement)((.+))?: .{1,50}/ |
| 9 | +``` |
| 10 | + |
| 11 | +## Commit Message Format |
| 12 | +A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: |
| 13 | + |
| 14 | +> The **scope** is optional |
| 15 | +
|
| 16 | +``` |
| 17 | +feat(router): add support for prefix |
| 18 | +
|
| 19 | +Prefix makes it easier to append a path to a group of routes |
| 20 | +``` |
| 21 | + |
| 22 | +1. `feat` is type. |
| 23 | +2. `router` is scope and is optional |
| 24 | +3. `add support for prefix` is the subject |
| 25 | +4. The **body** is followed by a blank line. |
| 26 | +5. The optional **footer** can be added after the body, followed by a blank line. |
| 27 | + |
| 28 | +## Types |
| 29 | +Only one type can be used at a time and only following types are allowed. |
| 30 | + |
| 31 | +- feat |
| 32 | +- fix |
| 33 | +- docs |
| 34 | +- style |
| 35 | +- refactor |
| 36 | +- perf |
| 37 | +- test |
| 38 | +- workflow |
| 39 | +- ci |
| 40 | +- chore |
| 41 | +- types |
| 42 | +- build |
| 43 | + |
| 44 | +If a type is `feat`, `fix` or `perf`, then the commit will appear in the CHANGELOG.md file. However if there is any BREAKING CHANGE, the commit will always appear in the changelog. |
| 45 | + |
| 46 | +### Revert |
| 47 | +If the commit reverts a previous commit, it should begin with `revert:`, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>`., where the hash is the SHA of the commit being reverted. |
| 48 | + |
| 49 | +## Scope |
| 50 | +The scope could be anything specifying place of the commit change. For example: `router`, `view`, `querybuilder`, `database`, `model` and so on. |
| 51 | + |
| 52 | +## Subject |
| 53 | +The subject contains succinct description of the change: |
| 54 | + |
| 55 | +- use the imperative, present tense: "change" not "changed" nor "changes". |
| 56 | +- don't capitalize first letter |
| 57 | +- no dot (.) at the end |
| 58 | + |
| 59 | +## Body |
| 60 | + |
| 61 | +Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". |
| 62 | +The body should include the motivation for the change and contrast this with previous behavior. |
| 63 | + |
| 64 | +## Footer |
| 65 | + |
| 66 | +The footer should contain any information about **Breaking Changes** and is also the place to |
| 67 | +reference GitHub issues that this commit **Closes**. |
| 68 | + |
| 69 | +**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this. |
| 70 | + |
0 commit comments