You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ci: validate the message of each new commit as part of the CI linting
This patch adds the gulp command of `validate-commit-messages`
which will validate the range of commits messages present in the
active branch.
This check now runs on CI as part of the linting checks.
Allowed commit message types and scopes are controlled via commit-message.json file
and documented at https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines
This solution is based on old Vojta's code that he wrote for angular/angular.js, that was later adjusted
by @matsko in #13815.
Ideally we should switch over to something like https://www.npmjs.com/package/commitplease
as suggested in #9953 but that package currently doesn't support strict scope checking,
which is one of the primarily goal of this PR.
Note that this PR removes support for "chore" which was previously overused
by everyone on the team.
Closes#13815Fixes#3337
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+33-8Lines changed: 33 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -191,21 +191,46 @@ If the commit reverts a previous commit, it should begin with `revert: `, follow
191
191
### Type
192
192
Must be one of the following:
193
193
194
+
***build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
195
+
***ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
196
+
***docs**: Documentation only changes
194
197
***feat**: A new feature
195
198
***fix**: A bug fix
196
-
***docs**: Documentation only changes
199
+
***perf**: A code change that improves performance
200
+
***refactor**: A code change that neither fixes a bug nor adds a feature
197
201
***style**: Changes that do not affect the meaning of the code (white-space, formatting, missing
198
202
semi-colons, etc)
199
-
***refactor**: A code change that neither fixes a bug nor adds a feature
200
-
***perf**: A code change that improves performance
201
203
***test**: Adding missing tests or correcting existing tests
202
-
***build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
203
-
***ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
204
-
***chore**: Other changes that don't modify `src` or `test` files
205
204
206
205
### Scope
207
-
The scope could be anything specifying place of the commit change. For example
208
-
`Compiler`, `ElementInjector`, etc.
206
+
The scope should be the name of the npm package affected (as perceived by person reading changelog generated from commit messages.
207
+
208
+
The following is the list of supported scopes:
209
+
210
+
***common**
211
+
***compiler**
212
+
***compiler-cli**
213
+
***core**
214
+
***forms**
215
+
***http**
216
+
***language-service**
217
+
***platform-browser**
218
+
***platform-browser-dynamic**
219
+
***platform-server**
220
+
***platform-webworker**
221
+
***platform-webworker-dynamic**
222
+
***router**
223
+
***upgrade**
224
+
***tsc-wrapped**
225
+
226
+
There is currently few exception to the "use package name" rule:
227
+
228
+
***packaging**: used forchanges that change the npm package layoutin all of our packages, e.g. public path changes, package.json changes done to all packages, d.ts file/format changes, changes to bundles, etc.
229
+
***changelog**: used forupdating the release notesin CHANGELOG.md
230
+
* none/empty string: useful for`style`, `test` and `refactor` changes that are done across all packages (e.g. `style: add missing semicolons`)
231
+
232
+
233
+
Packaging
209
234
210
235
### Subject
211
236
The subject contains succinct description of the change:
'fix(compiler): something super mega extra giga tera long, maybe even longer and longer and longer... ';
72
+
73
+
expect(validateMessage(msg)).toBe(INVALID);
74
+
expect(errors).toEqual([
75
+
'INVALID COMMIT MSG: "fix(compiler): something super mega extra giga tera long, maybe even longer and longer and longer... "\n => ERROR: The commit message is longer than 100 characters'
'INVALID COMMIT MSG: "not correct format"\n => ERROR: The commit message does not match the format of "<type>(<scope>): <subject> OR revert: type(<scope>): <subject>"'
86
+
]);
87
+
});
88
+
89
+
90
+
it('should support "revert: type(scope):" syntax and reject "revert(scope):" syntax',function(){
91
+
letcorrectMsg='revert: fix(compiler): reduce generated code payload size by 65%';
92
+
expect(validateMessage(correctMsg)).toBe(VALID);
93
+
94
+
letincorretMsg='revert(compiler): reduce generated code payload size by 65%';
'INVALID COMMIT MSG: "revert(compiler): reduce generated code payload size by 65%"\n => ERROR: The commit message does not match the format of "<type>(<scope>): <subject> OR revert: type(<scope>): <subject>"'
0 commit comments