@@ -20,18 +20,20 @@ const fs = require('fs')
20
20
// const core = require('@actions/core')
21
21
// const github = require('@actions/github')
22
22
23
- const topics = new Set ( [
23
+ const types = new Set ( [
24
24
'build' ,
25
25
// Don't allow "chore" because it's over-used.
26
- // Instead, add a new topic if absolutely needed (if the existing ones can't possibly apply).
26
+ // Instead, add a new type if absolutely needed (if the existing ones can't possibly apply).
27
27
// 'chore',
28
28
'ci' ,
29
29
'config' ,
30
+ 'deps' ,
30
31
'docs' ,
31
32
'feat' ,
32
33
'fix' ,
33
34
'perf' ,
34
35
'refactor' ,
36
+ 'revert' ,
35
37
'style' ,
36
38
'telemetry' ,
37
39
'test' ,
@@ -42,23 +44,26 @@ const topics = new Set([
42
44
const scopes = new Set ( [
43
45
'amazonq' ,
44
46
'core' ,
47
+ 'explorer' ,
45
48
'lambda' ,
46
49
'logs' ,
47
50
'redshift' ,
48
51
'q-chat' ,
49
52
'q-featuredev' ,
50
53
'q-inlinechat' ,
51
54
'q-transform' ,
55
+ 'sam' ,
52
56
's3' ,
53
57
'telemetry' ,
58
+ 'toolkit' ,
54
59
'ui' ,
55
60
] )
56
61
void scopes
57
62
58
63
/**
59
64
* Checks that a pull request title, or commit message subject, follows the expected format:
60
65
*
61
- * topic (scope): message
66
+ * type (scope): message
62
67
*
63
68
* Returns undefined if `title` is valid, else an error message.
64
69
*/
@@ -70,22 +75,20 @@ function validateTitle(title) {
70
75
return 'missing colon (:) char'
71
76
}
72
77
73
- const topicScope = parts [ 0 ]
78
+ const typeScope = parts [ 0 ]
74
79
75
- if ( topicScope . startsWith ( 'revert' ) ) {
76
- return validateTitle ( subject )
77
- }
78
-
79
- const [ topic , scope ] = topicScope . split ( / \( ( [ ^ ) ] + ) \) $ / )
80
+ const [ type , scope ] = typeScope . split ( / \( ( [ ^ ) ] + ) \) $ / )
80
81
81
- if ( / \s + / . test ( topic ) ) {
82
- return `topic contains whitespace: "${ topic } "`
83
- } else if ( topic === 'chore' ) {
84
- return 'do not use "chore" as a topic. If the existing valid topics are insufficent, add a new topic to the `lintcommit.js` script.'
85
- } else if ( ! topics . has ( topic ) ) {
86
- return `invalid topic "${ topic } "`
87
- } else if ( ! scope && topicScope . includes ( '(' ) ) {
88
- return `must be formatted like topic(scope):`
82
+ if ( / \s + / . test ( type ) ) {
83
+ return `type contains whitespace: "${ type } "`
84
+ } else if ( type === 'chore' ) {
85
+ return 'Do not use "chore" as a type. If the existing valid types are insufficent, add a new type to the `lintcommit.js` script.'
86
+ } else if ( ! types . has ( type ) ) {
87
+ return `invalid type "${ type } "`
88
+ } else if ( ! scope && typeScope . includes ( '(' ) ) {
89
+ return `must be formatted like type(scope):`
90
+ } else if ( ! scope && [ 'feat' , 'fix' ] . includes ( type ) ) {
91
+ return `"${ type } " type must include a scope (example: "${ type } (amazonq)")`
89
92
} else if ( scope && scope . length > 30 ) {
90
93
return 'invalid scope (must be <=30 chars)'
91
94
} else if ( scope && / [ ^ - a - z 0 - 9 ] + / . test ( scope ) ) {
@@ -115,14 +118,14 @@ function run() {
115
118
const failReason = validateTitle ( title )
116
119
const msg = failReason
117
120
? `
118
- Pull request title does not match the [expected format](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#pull-request- title):
121
+ Invalid pull request title: \` ${ title } \`
119
122
120
- * Title: \`${ title } \`
121
- * Reason: ${ failReason }
122
- * Expected format: \`topic(scope): subject...\`
123
- * topic: one of (${ Array . from ( topics ) . join ( ', ' ) } )
123
+ * Problem: ${ failReason }
124
+ * Expected format: \`type(scope): subject...\`
125
+ * type: one of (${ Array . from ( types ) . join ( ', ' ) } )
124
126
* scope: lowercase, <30 chars
125
127
* subject: must be <100 chars
128
+ * documentation: https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#pull-request-title
126
129
`
127
130
: `Pull request title matches the [expected format](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#pull-request-title).`
128
131
@@ -140,27 +143,28 @@ Pull request title does not match the [expected format](https://github.com/aws/a
140
143
141
144
function _test ( ) {
142
145
const tests = {
143
- ' foo(scope): bar' : 'topic contains whitespace: " foo"' ,
146
+ ' foo(scope): bar' : 'type contains whitespace: " foo"' ,
144
147
'build: update build process' : undefined ,
145
148
'chore: update dependencies' :
146
- 'do not use "chore" as a topic . If the existing valid topics are insufficent, add a new topic to the `lintcommit.js` script.' ,
149
+ 'Do not use "chore" as a type . If the existing valid types are insufficent, add a new type to the `lintcommit.js` script.' ,
147
150
'ci: configure CI/CD' : undefined ,
148
151
'config: update configuration files' : undefined ,
152
+ 'deps: bump the aws-sdk group across 1 directory with 5 updates' : undefined ,
149
153
'docs: update documentation' : undefined ,
150
154
'feat(foo): add new feature' : undefined ,
151
155
'feat(foo):' : 'empty subject' ,
152
- 'feat foo):' : 'topic contains whitespace: "feat foo)"' ,
153
- 'feat(foo)): sujet' : 'invalid topic "feat(foo))"' ,
154
- 'feat(foo: sujet' : 'invalid topic "feat(foo"' ,
155
- 'feat(q foo bar): bar' :
156
- 'do not use "chore" as a topic. If the existing valid topics are insufficent, add a new topic to the `lintcommit.js` script.' ,
156
+ 'feat foo):' : 'type contains whitespace: "feat foo)"' ,
157
+ 'feat(foo)): sujet' : 'invalid type "feat(foo))"' ,
158
+ 'feat(foo: sujet' : 'invalid type "feat(foo"' ,
157
159
'feat(Q Foo Bar): bar' : 'invalid scope (must be lowercase, ascii only): "Q Foo Bar"' ,
158
160
'feat(scope):' : 'empty subject' ,
159
161
'feat(q foo bar): bar' : undefined ,
160
162
'feat(foo): x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x ' :
161
163
'invalid subject (must be <=100 chars)' ,
164
+ 'feat: foo' : '"feat" type must include a scope (example: "feat(amazonq)")' ,
165
+ 'fix: foo' : '"fix" type must include a scope (example: "fix(amazonq)")' ,
162
166
'fix(a-b-c): resolve issue' : undefined ,
163
- 'foo (scope): bar' : 'topic contains whitespace: "foo "' ,
167
+ 'foo (scope): bar' : 'type contains whitespace: "foo "' ,
164
168
'invalid title' : 'missing colon (:) char' ,
165
169
'perf: optimize performance' : undefined ,
166
170
'refactor: improve code structure' : undefined ,
0 commit comments