@@ -11,7 +11,10 @@ test.beforeEach(t => {
11
11
} ) ;
12
12
13
13
test ( 'Parse with "conventional-changelog-angular" by default' , async t => {
14
- const commits = [ { message : 'fix(scope1): First fix' } , { message : 'feat(scope2): Second feature' } ] ;
14
+ const commits = [
15
+ { hash : '123' , message : 'fix(scope1): First fix' } ,
16
+ { hash : '456' , message : 'feat(scope2): Second feature' } ,
17
+ ] ;
15
18
const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
16
19
17
20
t . is ( releaseType , 'minor' ) ;
@@ -23,7 +26,10 @@ test('Parse with "conventional-changelog-angular" by default', async t => {
23
26
} ) ;
24
27
25
28
test ( 'Accept "preset" option' , async t => {
26
- const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
29
+ const commits = [
30
+ { hash : '123' , message : 'Fix: First fix (fixes #123)' } ,
31
+ { hash : '456' , message : 'Update: Second feature (fixes #456)' } ,
32
+ ] ;
27
33
const releaseType = await analyzeCommits ( { preset : 'eslint' } , { cwd, commits, logger : t . context . logger } ) ;
28
34
29
35
t . is ( releaseType , 'minor' ) ;
@@ -35,7 +41,10 @@ test('Accept "preset" option', async t => {
35
41
} ) ;
36
42
37
43
test ( 'Accept "config" option' , async t => {
38
- const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
44
+ const commits = [
45
+ { hash : '123' , message : 'Fix: First fix (fixes #123)' } ,
46
+ { hash : '456' , message : 'Update: Second feature (fixes #456)' } ,
47
+ ] ;
39
48
const releaseType = await analyzeCommits (
40
49
{ config : 'conventional-changelog-eslint' } ,
41
50
{ cwd, commits, logger : t . context . logger }
@@ -51,8 +60,8 @@ test('Accept "config" option', async t => {
51
60
52
61
test ( 'Accept a "parseOpts" object as option' , async t => {
53
62
const commits = [
54
- { message : '%%BUGFIX%% First fix (fixes #123)' } ,
55
- { message : '%%FEATURE%% Second feature (fixes #456)' } ,
63
+ { hash : '123' , message : '%%BUGFIX%% First fix (fixes #123)' } ,
64
+ { hash : '456' , message : '%%FEATURE%% Second feature (fixes #456)' } ,
56
65
] ;
57
66
const releaseType = await analyzeCommits (
58
67
{ parserOpts : { headerPattern : / ^ % % ( .* ?) % % ( .* ) $ / , headerCorrespondence : [ 'tag' , 'shortDesc' ] } } ,
@@ -68,7 +77,10 @@ test('Accept a "parseOpts" object as option', async t => {
68
77
} ) ;
69
78
70
79
test ( 'Accept a partial "parseOpts" object as option' , async t => {
71
- const commits = [ { message : '%%fix%% First fix (fixes #123)' } , { message : '%%Update%% Second feature (fixes #456)' } ] ;
80
+ const commits = [
81
+ { hash : '123' , message : '%%fix%% First fix (fixes #123)' } ,
82
+ { hash : '456' , message : '%%Update%% Second feature (fixes #456)' } ,
83
+ ] ;
72
84
const releaseType = await analyzeCommits (
73
85
{
74
86
config : 'conventional-changelog-eslint' ,
@@ -100,7 +112,10 @@ test('Exclude commits if they have a matching revert commits', async t => {
100
112
} ) ;
101
113
102
114
test ( 'Accept a "releaseRules" option that reference a requierable module' , async t => {
103
- const commits = [ { message : 'fix(scope1): First fix' } , { message : 'feat(scope2): Second feature' } ] ;
115
+ const commits = [
116
+ { hash : '123' , message : 'fix(scope1): First fix' } ,
117
+ { hash : '456' , message : 'feat(scope2): Second feature' } ,
118
+ ] ;
104
119
const releaseType = await analyzeCommits (
105
120
{ releaseRules : './test/fixtures/release-rules' } ,
106
121
{ cwd, commits, logger : t . context . logger }
@@ -116,8 +131,8 @@ test('Accept a "releaseRules" option that reference a requierable module', async
116
131
117
132
test ( 'Return "major" if there is a breaking change, using default releaseRules' , async t => {
118
133
const commits = [
119
- { message : 'Fix: First fix (fixes #123)' } ,
120
- { message : 'Update: Second feature (fixes #456) \n\n BREAKING CHANGE: break something' } ,
134
+ { hash : '123' , message : 'Fix: First fix (fixes #123)' } ,
135
+ { hash : '456' , message : 'Update: Second feature (fixes #456) \n\n BREAKING CHANGE: break something' } ,
121
136
] ;
122
137
const releaseType = await analyzeCommits ( { preset : 'eslint' } , { cwd, commits, logger : t . context . logger } ) ;
123
138
@@ -130,7 +145,10 @@ test('Return "major" if there is a breaking change, using default releaseRules',
130
145
} ) ;
131
146
132
147
test ( 'Return "patch" if there is only types set to "patch", using default releaseRules' , async t => {
133
- const commits = [ { message : 'fix: First fix (fixes #123)' } , { message : 'perf: perf improvement' } ] ;
148
+ const commits = [
149
+ { hash : '123' , message : 'fix: First fix (fixes #123)' } ,
150
+ { hash : '456' , message : 'perf: perf improvement' } ,
151
+ ] ;
134
152
const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
135
153
136
154
t . is ( releaseType , 'patch' ) ;
@@ -142,7 +160,10 @@ test('Return "patch" if there is only types set to "patch", using default releas
142
160
} ) ;
143
161
144
162
test ( 'Allow to use regex in "releaseRules" configuration' , async t => {
145
- const commits = [ { message : 'Chore: First chore (fixes #123)' } , { message : 'Docs: update README (fixes #456)' } ] ;
163
+ const commits = [
164
+ { hash : '123' , message : 'Chore: First chore (fixes #123)' } ,
165
+ { hash : '456' , message : 'Docs: update README (fixes #456)' } ,
166
+ ] ;
146
167
const releaseType = await analyzeCommits (
147
168
{ preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } , { message : '/README/' , release : 'minor' } ] } ,
148
169
{ cwd, commits, logger : t . context . logger }
@@ -157,7 +178,7 @@ test('Allow to use regex in "releaseRules" configuration', async t => {
157
178
} ) ;
158
179
159
180
test ( 'Return "null" if no rule match' , async t => {
160
- const commits = [ { message : 'doc: doc update' } , { message : 'chore: Chore' } ] ;
181
+ const commits = [ { hash : '123' , message : 'doc: doc update' } , { hash : '456' , message : 'chore: Chore' } ] ;
161
182
const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
162
183
163
184
t . is ( releaseType , null ) ;
@@ -169,7 +190,10 @@ test('Return "null" if no rule match', async t => {
169
190
} ) ;
170
191
171
192
test ( 'Process rules in order and apply highest match' , async t => {
172
- const commits = [ { message : 'Chore: First chore (fixes #123)' } , { message : 'Docs: update README (fixes #456)' } ] ;
193
+ const commits = [
194
+ { hash : '123' , message : 'Chore: First chore (fixes #123)' } ,
195
+ { hash : '456' , message : 'Docs: update README (fixes #456)' } ,
196
+ ] ;
173
197
const releaseType = await analyzeCommits (
174
198
{ preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'minor' } , { tag : 'Chore' , release : 'patch' } ] } ,
175
199
{ cwd, commits, logger : t . context . logger }
@@ -185,8 +209,8 @@ test('Process rules in order and apply highest match', async t => {
185
209
186
210
test ( 'Process rules in order and apply highest match from config even if default has an higher match' , async t => {
187
211
const commits = [
188
- { message : 'Chore: First chore (fixes #123)' } ,
189
- { message : 'Docs: update README (fixes #456) \n\n BREAKING CHANGE: break something' } ,
212
+ { hash : '123' , message : 'Chore: First chore (fixes #123)' } ,
213
+ { hash : '456' , message : 'Docs: update README (fixes #456) \n\n BREAKING CHANGE: break something' } ,
190
214
] ;
191
215
const releaseType = await analyzeCommits (
192
216
{ preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } , { breaking : true , release : 'minor' } ] } ,
@@ -202,7 +226,7 @@ test('Process rules in order and apply highest match from config even if default
202
226
} ) ;
203
227
204
228
test ( 'Allow to overwrite default "releaseRules" with "false"' , async t => {
205
- const commits = [ { message : 'chore: First chore' } , { message : 'feat: new feature' } ] ;
229
+ const commits = [ { hash : '123' , message : 'chore: First chore' } , { hash : '456' , message : 'feat: new feature' } ] ;
206
230
const releaseType = await analyzeCommits (
207
231
{ preset : 'angular' , releaseRules : [ { type : 'feat' , release : false } ] } ,
208
232
{ cwd, commits, logger : t . context . logger }
@@ -217,7 +241,7 @@ test('Allow to overwrite default "releaseRules" with "false"', async t => {
217
241
} ) ;
218
242
219
243
test ( 'Commits with an associated custom release type have higher priority than commits with release "false"' , async t => {
220
- const commits = [ { message : 'feat: Feature to skip' } , { message : 'docs: update README' } ] ;
244
+ const commits = [ { hash : '123' , message : 'feat: Feature to skip' } , { hash : '456' , message : 'docs: update README' } ] ;
221
245
const releaseType = await analyzeCommits (
222
246
{ preset : 'angular' , releaseRules : [ { type : 'feat' , release : false } , { type : 'docs' , release : 'patch' } ] } ,
223
247
{ cwd, commits, logger : t . context . logger }
@@ -232,7 +256,7 @@ test('Commits with an associated custom release type have higher priority than c
232
256
} ) ;
233
257
234
258
test ( 'Commits with an associated default release type have higher priority than commits with release "false"' , async t => {
235
- const commits = [ { message : 'feat: new feature' } , { message : 'fix: new Fix' } ] ;
259
+ const commits = [ { hash : '123' , message : 'feat: new feature' } , { hash : '456' , message : 'fix: new Fix' } ] ;
236
260
const releaseType = await analyzeCommits (
237
261
{ preset : 'angular' , releaseRules : [ { type : 'feat' , release : false } ] } ,
238
262
{ cwd, commits, logger : t . context . logger }
@@ -247,7 +271,7 @@ test('Commits with an associated default release type have higher priority than
247
271
} ) ;
248
272
249
273
test ( 'Use default "releaseRules" if none of provided match' , async t => {
250
- const commits = [ { message : 'Chore: First chore' } , { message : 'Update: new feature' } ] ;
274
+ const commits = [ { hash : '123' , message : 'Chore: First chore' } , { hash : '456' , message : 'Update: new feature' } ] ;
251
275
const releaseType = await analyzeCommits (
252
276
{ preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } ] } ,
253
277
{ cwd, commits, logger : t . context . logger }
@@ -261,6 +285,13 @@ test('Use default "releaseRules" if none of provided match', async t => {
261
285
t . true ( t . context . log . calledWith ( 'Analysis of %s commits complete: %s release' , 2 , 'minor' ) ) ;
262
286
} ) ;
263
287
288
+ test ( 'Filter out empty commits' , async t => {
289
+ const commits = [ { hash : '123' , message : '' } , { hash : '456' , message : 'fix(scope1): First fix' } ] ;
290
+ const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
291
+
292
+ t . is ( releaseType , 'patch' ) ;
293
+ } ) ;
294
+
264
295
test ( 'Throw error if "preset" doesn`t exist' , async t => {
265
296
await t . throwsAsync ( analyzeCommits ( { preset : 'unknown-preset' } , { cwd} ) , { code : 'MODULE_NOT_FOUND' } ) ;
266
297
} ) ;
0 commit comments