Skip to content

Commit a2261bb

Browse files
committed
build: use matching commitlint config
The commit conventions enforced by commitlint (conventional) were different than the conventions used by the semantic-release (angular). In practice, is was never a problem as they are pretty similar, but it's better to be consistent anyways. Update the commit conventions documentation according to the change and also extend it with the information about which kind of release is triggered by which commit type. Add explicit configuration for release rules for semantic-release to the configuration file - rules are the same as before, but now it is easier to see what they actually are.
1 parent 920fa33 commit a2261bb

5 files changed

Lines changed: 53 additions & 30 deletions

File tree

commitlint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = { extends: ['@commitlint/config-conventional'] }
1+
module.exports = { extends: ['@commitlint/config-angular'] }

docs/dev/06-git-commit-msg.md

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
showInMenu: false
33
---
44

5+
In the repository we use and enforce the commit message conventions. The conventions are verified using [commitlint] with [Angular config](https://www.npmjs.com/package/@commitlint/config-angular).
6+
57
## The reasons for these conventions:
68
- automatic generating of the changelog
79
- simple navigation through git history (e.g. ignoring style changes)
810

911
## Format of the commit message:
1012
```bash
1113
<type>(<scope>): <subject>
12-
14+
<BLANK LINE>
1315
<body>
14-
16+
<BLANK LINE>
1517
<footer>
1618
```
1719

@@ -27,19 +29,18 @@ Fixes #2310
2729
```
2830

2931
## Message subject (first line)
30-
The first line cannot be longer than 70 characters, the second line is always blank and
31-
other lines should be wrapped at 80 characters. The type and scope should
32-
always be lowercase as shown below.
32+
The first line cannot be longer than 72 characters and should be followed by a blank line. The type and scope should always be lowercase as shown below.
3333

3434
### Allowed `<type>` values:
3535

36-
* **feat** (new feature for the user, not a new feature for build script)
37-
* **fix** (bug fix for the user, not a fix to a build script)
38-
* **docs** (changes to the documentation)
39-
* **style** (formatting, missing semi colons, etc; no production code change)
40-
* **refactor** (refactoring production code, eg. renaming a variable)
41-
* **test** (adding missing tests, refactoring tests; no production code change)
42-
* **chore** (updating grunt tasks etc; no production code change)
36+
* **feat** for a new feature for the user, not a new feature for build script. Such commit will trigger a release bumping a MINOR version.
37+
* **fix** for a bug fix for the user, not a fix to a build script. Such commit will trigger a release bumping a PATCH version.
38+
* **perf** for performance improvements. Such commit will trigger a release bumping a PATCH version.
39+
* **docs** for changes to the documentation.
40+
* **style** for formatting changes, missing semicolons, etc.
41+
* **refactor** for refactoring production code, e.g. renaming a variable.
42+
* **test** for adding missing tests, refactoring tests; no production code change.
43+
* **build** for updating build configuration, development tools or other changes irrelevant to the user.
4344

4445
### Example `<scope>` values:
4546

@@ -55,16 +56,9 @@ The `<scope>` can be empty (e.g. if the change is a global or difficult
5556
to assign to a single component), in which case the parentheses are
5657
omitted. In smaller projects such as Karma plugins, the `<scope>` is empty.
5758

58-
5959
## Message body
60-
* uses the imperative, present tense: “change” not “changed” nor “changes”
61-
* includes motivation for the change and contrasts with previous behavior
62-
63-
For more info about message body, see:
64-
65-
* https://365git.tumblr.com/post/3308646748/writing-git-commit-messages
66-
* https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
6760

61+
Just as in the `<subject>`, use the imperative, present tense: "change" not "changed" nor "changes". Message body should include motivation for the change and contrasts with previous behavior.
6862

6963
## Message footer
7064

@@ -91,10 +85,13 @@ To migrate your project, change all the commands, where you use `--port-runner`
9185
to `--runner-port`.
9286
```
9387

88+
Any commit with the breaking change section will trigger a MAJOR release and appear on the changelog independently of the commit type.
89+
9490
---
9591

96-
This document is based on [AngularJS Git Commit Msg Convention]. See the
97-
[commit history] for examples of properly-formatted commit messages.
92+
This document is based on [Angular Commit Message Format]. See the [commit history] for examples of properly-formatted commit messages.
9893

99-
[AngularJS Git Commit Msg Convention]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
94+
[commitlint]: https://conventional-changelog.github.io/commitlint/
95+
[Angular config]: https://www.npmjs.com/package/@commitlint/config-angular
96+
[Angular Commit Message Format]: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit
10097
[commit history]: https://github.com/karma-runner/karma/commits/master

package-lock.json

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@
445445
},
446446
"devDependencies": {
447447
"@commitlint/cli": "^12.1.4",
448-
"@commitlint/config-conventional": "^12.1.4",
448+
"@commitlint/config-angular": "^12.1.4",
449449
"@semantic-release/changelog": "^5.0.1",
450450
"@semantic-release/git": "^9.0.1",
451451
"browserify": "^16.2.3",

release.config.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,25 @@ module.exports = {
2020
success: [
2121
'@semantic-release/github',
2222
'./tools/update-docs'
23-
]
23+
],
24+
25+
// The release rules determine what kind of release should be triggered
26+
// based on the information included in the commit message. The default
27+
// rules used by semantic-release are the same, but they are set explicitly
28+
// for better visibility.
29+
// See https://github.com/semantic-release/commit-analyzer/blob/master/lib/default-release-rules.js
30+
releaseRules: [
31+
{ breaking: true, release: 'major' },
32+
{ revert: true, release: 'patch' },
33+
{ type: 'feat', release: 'minor' },
34+
{ type: 'fix', release: 'patch' },
35+
{ type: 'perf', release: 'patch' }
36+
],
37+
38+
// The preset determines which commits are included in the changelog and how
39+
// the changelog is formatted. The default value used by semantic-release is
40+
// the same, but it is set explicitly for visibility.
41+
// See https://semantic-release.gitbook.io/semantic-release/#commit-message-format
42+
// See https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular
43+
preset: 'angular'
2444
}

0 commit comments

Comments
 (0)