@@ -11,6 +11,7 @@ The parser can identify:
11
11
- GitLab [ closing keywords] ( https://docs.gitlab.com/ee/user/project/issues/automatic_issue_closing.html ) , [ duplicate keyword] ( https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12845 ) , [ issue references] ( https://about.gitlab.com/2016/03/08/gitlab-tutorial-its-all-connected ) and [ user mentions] ( https://about.gitlab.com/2016/03/08/gitlab-tutorial-its-all-connected )
12
12
- Bitbucket [ closing keywords] ( https://confluence.atlassian.com/bitbucket/resolve-issues-automatically-when-users-push-code-221451126.html ) , [ issue references] ( https://confluence.atlassian.com/bitbucket/mark-up-comments-issues-and-commit-messages-321859781.html ) and [ user mentions] ( https://confluence.atlassian.com/bitbucket/mark-up-comments-issues-and-commit-messages-321859781.html )
13
13
- Waffle.io [ epics] ( https://help.waffle.io/epics/which-keywords-are-supported-with-epics ) and [ dependencies] ( https://help.waffle.io/dependencies/which-keywords-are-supported-with-dependencies ) keywords
14
+ - [ Custom] ( #custom-format ) or [ additional] ( #extend-existing-format ) keywords
14
15
15
16
## Install
16
17
@@ -30,8 +31,10 @@ parse('Issue description, ref user/package#1, Fix #2, Duplicate of #3 /cc @user'
30
31
/*
31
32
{
32
33
refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}],
33
- actions: [{raw: 'Fix #2', action: 'Fix', prefix: '#', issue: '2'}],
34
- duplicates: [{raw: 'Duplicate of #3', action: 'Duplicate of', prefix: '#', issue: '3'}],
34
+ actions: {
35
+ close: [{raw: 'Fix #2', action: 'Fix', prefix: '#', issue: '2'}],
36
+ duplicate: [{raw: 'Duplicate of #3', action: 'Duplicate of', prefix: '#', issue: '3'}],
37
+ },
35
38
mentions: [{raw: '@user', prefix: '@', user: 'user'}],
36
39
}
37
40
*/
@@ -50,8 +53,10 @@ parse('Issue description, ref group/user/package#1, !2, implement #3, /duplicate
50
53
{raw: 'group/user/package#1', slug: 'group/user/package', prefix: '#', issue: '1'},
51
54
{raw: '!2', slug: 'group/user/package', prefix: '!', issue: '2'},
52
55
],
53
- actions: [{raw: 'implement #3', action: 'Implement', prefix: '#', issue: '4'}],
54
- duplicates: [{raw: 'Duplicate of #4', action: 'Duplicate of', prefix: '#', issue: '4'}],
56
+ actions: {
57
+ close: [{raw: 'implement #3', action: 'Implement', prefix: '#', issue: '4'}],
58
+ duplicate: [{raw: 'Duplicate of #4', action: 'Duplicate of', prefix: '#', issue: '4'}],
59
+ },
55
60
mentions: [{raw: '@user', prefix: '@', user: 'user'}],
56
61
}
57
62
*/
@@ -67,7 +72,9 @@ parse('Issue description, ref user/package#1, fixing #2. /cc @user');
67
72
/*
68
73
{
69
74
refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}],
70
- actions: [{raw: 'fixing #2', action: 'Fixing', prefix: '#', issue: '2'}],
75
+ actions: {
76
+ close: [{raw: 'fixing #2', action: 'Fixing', prefix: '#', issue: '2'}],
77
+ },
71
78
mentions: [{raw: '@user', prefix: '@', user: 'user'}],
72
79
}
73
80
*/
@@ -83,11 +90,13 @@ parse('Issue description, ref user/package#1, Fix #2, blocks user/package#3, Req
83
90
/*
84
91
{
85
92
refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}],
86
- actions: [{raw: 'Fix #2', action: 'Fix', prefix: '#', issue: '2'}],
87
- blocks: [{raw: 'blocks user/package#3', action: 'Blocks', slug: 'user/package', prefix: '#', issue: '3'}],
88
- requires: [{raw: 'Require #4', action: 'Require', prefix: '#', issue: '4'}],
89
- parentOf: [{raw: 'Parent of #5', action: 'Parent of', prefix: '#', issue: '5'}],
90
- childOf: [{raw: 'Child of #6', action: 'Child of', prefix: '#', issue: '6'}],
93
+ actions: {
94
+ close: [{raw: 'Fix #2', action: 'Fix', prefix: '#', issue: '2'}],
95
+ block: [{raw: 'blocks user/package#3', action: 'Blocks', slug: 'user/package', prefix: '#', issue: '3'}],
96
+ require: [{raw: 'Require #4', action: 'Require', prefix: '#', issue: '4'}],
97
+ parentOf: [{raw: 'Parent of #5', action: 'Parent of', prefix: '#', issue: '5'}],
98
+ childOf: [{raw: 'Child of #6', action: 'Child of', prefix: '#', issue: '6'}],
99
+ },
91
100
mentions: [{raw: '@user', prefix: '@', user: 'user'}],
92
101
}
93
102
*/
@@ -97,14 +106,36 @@ parse('Issue description, ref user/package#1, Fix #2, blocks user/package#3, Req
97
106
98
107
``` js
99
108
const issueParser = require (' issue-parser' );
100
- const parse = issueParser ({referenceActions : [' complete' ], blocksActions : [' holds up' ], issuePrefixes: [' 🐛' ]});
109
+ const parse = issueParser ({actions : {fix : [' complete' ], hold : [' holds up' ]} , issuePrefixes: [' 🐛' ]});
101
110
102
111
parse (' Issue description, related to user/package🐛1, Complete 🐛2, holds up 🐛3' );
103
112
/*
104
113
{
105
114
refs: [{raw: 'user/package🐛1', slug: 'user/package', prefix: '🐛', issue: '1'}],
106
- actions: [{raw: 'Complete 🐛2', action: 'Complete', prefix: '🐛', issue: '2'}],
107
- blocks: [{raw: 'holds up 🐛3', action: 'Holds up', prefix: '🐛', issue: '3'}],
115
+ actions: {
116
+ fix: [{raw: 'Complete 🐛2', action: 'Complete', prefix: '🐛', issue: '2'}],
117
+ hold: [{raw: 'holds up 🐛3', action: 'Holds up', prefix: '🐛', issue: '3'}],
118
+ },
119
+ }
120
+ */
121
+ ```
122
+
123
+ ### Extend existing format
124
+
125
+ ``` js
126
+ const issueParser = require (' issue-parser' );
127
+ const parse = issueParser (' github' , {actions: {parent: [' parent of' ], related: [' related to' ]}});
128
+
129
+ parse (' Issue description, ref user/package#1, Fix #2, Parent of #3, related to #4 /cc @user' );
130
+ /*
131
+ {
132
+ refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}],
133
+ actions: {
134
+ close: [{raw: 'Fix #2', action: 'Fix', prefix: '#', issue: '2'}],
135
+ parent: [{raw: 'Parent of #3', action: 'Parent of', prefix: '#', issue: '3'}],
136
+ related: [{raw: 'related to #4', action: 'Related to', prefix: '#', issue: '4'}],
137
+ },
138
+ mentions: [{raw: '@user', prefix: '@', user: 'user'}],
108
139
}
109
140
*/
110
141
```
@@ -135,7 +166,7 @@ owner/repo#1
135
166
Fix #1
136
167
```
137
168
``` js
138
- {actions: [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]}
169
+ {actions: {close : [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]} }
139
170
```
140
171
141
172
### Parse duplicate keywords
@@ -144,7 +175,7 @@ Fix #1
144
175
Duplicate of #1
145
176
```
146
177
``` js
147
- {duplicates : [{raw: ' Duplicate of #1' , action: ' Duplicate of' , slug: undefined , prefix: ' #' , issue: ' 1' }]}
178
+ {actions : {duplicate : [{raw: ' Duplicate of #1' , action: ' Duplicate of' , slug: undefined , prefix: ' #' , issue: ' 1' }]} }
148
179
```
149
180
150
181
### Parse user mentions
@@ -166,9 +197,11 @@ Fix https://github.com/owner/repo/issues/2
166
197
``` js
167
198
{
168
199
refs: [{raw: ' https://github.com/owner/repo/pull/1' , slug: ' owner/repo' , prefix: undefined , issue: ' 1' },]
169
- actions: [
170
- {raw: ' Fix https://github.com/owner/repo/issues/2' , action: ' Fix' , slug: ' owner/repo' , prefix: undefined , issue: ' 2' }
171
- ]
200
+ actions: {
201
+ close: [
202
+ {raw: ' Fix https://github.com/owner/repo/issues/2' , action: ' Fix' , slug: ' owner/repo' , prefix: undefined , issue: ' 2' }
203
+ ]
204
+ }
172
205
}
173
206
```
174
207
@@ -178,7 +211,7 @@ Fix https://github.com/owner/repo/issues/2
178
211
FIX #1
179
212
```
180
213
``` js
181
- {actions: [{raw: ' FIX #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]}
214
+ {actions: {close : [{raw: ' FIX #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]} }
182
215
```
183
216
184
217
### Ignore references in back-tick quotes
@@ -188,7 +221,7 @@ Fix #1 `Fix #2` @user1 `@user2`
188
221
```
189
222
``` js
190
223
{
191
- actions: [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }],
224
+ actions: {close : [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]} ,
192
225
mentions: [{raw: ' @user1' , prefix: ' @' , user: ' user1' }]
193
226
}
194
227
```
@@ -200,7 +233,7 @@ Fix #1 `Fix #2` @user1 `@user2`
200
233
```
201
234
``` js
202
235
{
203
- actions: [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }],
236
+ actions: {close : [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]} ,
204
237
mentions: [{raw: ' @user1' , prefix: ' @' , user: ' user1' }]
205
238
}
206
239
```
@@ -222,7 +255,7 @@ console.log('@user2');
222
255
````
223
256
``` js
224
257
{
225
- actions: [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }],
258
+ actions: {close : [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]} ,
226
259
mentions: [{raw: ' @user1' , prefix: ' @' , user: ' user1' }]
227
260
}
228
261
```
@@ -240,7 +273,7 @@ Fix #1
240
273
```
241
274
``` js
242
275
{
243
- actions: [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }],
276
+ actions: {close : [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]} ,
244
277
mentions: [{raw: ' @user' , prefix: ' @' , user: ' user' }]
245
278
}
246
279
```
@@ -256,7 +289,7 @@ Fix #1
256
289
```
257
290
``` js
258
291
{
259
- actions: [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }],
292
+ actions: {close : [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]} ,
260
293
mentions: [{raw: ' @user1' , prefix: ' @' , user: ' user1' }]
261
294
}
262
295
```
@@ -269,7 +302,7 @@ Fix #1
269
302
```
270
303
``` js
271
304
{
272
- actions: [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }],
305
+ actions: {close : [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]} ,
273
306
mentions: [{raw: ' @user' , prefix: ' @' , user: ' user' }]
274
307
}
275
308
```
@@ -280,7 +313,7 @@ Fix #1
280
313
Fix #1 Fix #2a Fix a#3
281
314
```
282
315
``` js
283
- {actions: [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]}
316
+ {actions: {close : [{raw: ' Fix #1' , action: ' Fix' , slug: undefined , prefix: ' #' , issue: ' 1' }]} }
284
317
```
285
318
286
319
## API
@@ -294,47 +327,20 @@ Create a [parser](#parsetext--result).
294
327
Type: ` Object ` ` String ` <br >
295
328
Parser options. Can be ` github ` , ` gitlab ` or ` bitbucket ` for predefined options, or an object for custom options.
296
329
297
- ##### referenceActions
298
-
299
- Type: ` Array<String> ` ` String ` <br >
300
- Default: ` ['close', 'closes', 'closed', 'closing', 'fix', 'fixes', 'fixed', 'fixing', 'resolve', 'resolves', 'resolved', 'resolving', 'implement', 'implements', 'implemented', 'implementing'] `
301
-
302
- List of action keywords used to close issues and pull requests.
303
-
304
- ##### blocksActions
305
-
306
- Type: ` Array<String> ` ` String ` <br >
307
- Default: ` ['blocks', 'block', 'required by', 'needed by', 'dependency of'] `
308
-
309
- List of action keywords used to make an issue or pull request block another one.
310
-
311
- ##### requiresActions
312
-
313
- Type: ` Array<String> ` ` String ` <br >
314
- Default: ` ['blocked by', 'requires', 'require', 'need', 'needs', 'depends on'] `
315
-
316
- List of action keywords used to make an issue or pull request blocked by another one.
317
-
318
- ##### parentOfActions
330
+ ##### actions
319
331
320
- Type: ` Array<String> ` ` String ` <br >
321
- Default: ` ['parent of', 'parent to', 'parent'] `
322
-
323
- List of action keywords used to make an issue or pull request the parent of another one.
324
-
325
- ##### childOfActions
326
-
327
- Type: ` Array<String> ` ` String ` <br >
328
- Default: ` ['child of', 'child to', 'child'] `
329
-
330
- List of action keywords used to make an issue or pull request the child of another one.
331
-
332
- ##### duplicateActions
332
+ Type: ` Object ` <br >
333
+ Default:
334
+ `{close: [ 'close', 'closes', 'closed', 'closing', 'fix', 'fixes', 'fixed', 'fixing', 'resolve', 'resolves', 'resolved', 'resolving', 'implement', 'implements', 'implemented', 'implementing'] ,
335
+ block: [ 'blocks', 'block', 'required by', 'needed by', 'dependency of'] ,
336
+ require: [ 'blocked by', 'requires', 'require', 'need', 'needs', 'depends on'] ,
337
+ parentOf: [ 'parent of', 'parent to', 'parent'] ,
338
+ childOf: [ 'child of', 'child to', 'child'] ,
339
+ duplicate: [ 'Duplicate of', '/duplicate'] }`
333
340
334
- Type: ` Array<String> ` ` String ` <br >
335
- Default: ` ['Duplicate of', '/duplicate'] `
341
+ Object with type of action as key and array of keywords as value.
336
342
337
- List of keywords used to identify duplicate issues and pull requests .
343
+ Each keyword match will be placed in the corresponding property of the [ ` result ` ] ( #result ) ` action ` object. For example the with the configuration ` {actions: fix: ['fixed', 'fixing']} ` each action matching ` fixed ` or ` fixing ` will be under ` result.actions.fix ` .
338
344
339
345
##### mentionsPrefixes
340
346
@@ -389,10 +395,10 @@ Issue text to parse.
389
395
390
396
#### actions
391
397
392
- Type: ` Array< Object> `
398
+ Type: ` Object `
393
399
394
- List of issues and pull requests closed .<br >
395
- Each action has the following properties:
400
+ List of matching actions by type .<br >
401
+ Each type of action is an array of objects with the following properties:
396
402
397
403
| Name | Type | Description |
398
404
| --------| ----------| ---------------------------------------------------------------------------------------|
@@ -402,86 +408,11 @@ Each action has the following properties:
402
408
| prefix | ` String ` | The prefix used to identify the issue. |
403
409
| issue | ` String ` | The issue number. |
404
410
405
- #### blocks
406
-
407
- Type: ` Array<Object> `
408
-
409
- List of issues and pull requests blocked.<br >
410
- Each action has the following properties:
411
-
412
- | Name | Type | Description |
413
- | --------| ----------| ---------------------------------------------------------------------------------------|
414
- | raw | ` String ` | The raw value parsed, for example ` Blocks #1 ` . |
415
- | action | ` String ` | The keyword used to identify the action, capitalized. |
416
- | slug | ` String ` | The repository owner and name, for issue referred as ` <owner>/<repo>#<issue number> ` . |
417
- | prefix | ` String ` | The prefix used to identify the issue. |
418
- | issue | ` String ` | The issue number. |
419
-
420
- #### requires
421
-
422
- Type: ` Array<Object> `
423
-
424
- List of issues and pull requests required.<br >
425
- Each action has the following properties:
426
-
427
- | Name | Type | Description |
428
- | --------| ----------| ---------------------------------------------------------------------------------------|
429
- | raw | ` String ` | The raw value parsed, for example ` Requires #1 ` . |
430
- | action | ` String ` | The keyword used to identify the action, capitalized. |
431
- | slug | ` String ` | The repository owner and name, for issue referred as ` <owner>/<repo>#<issue number> ` . |
432
- | prefix | ` String ` | The prefix used to identify the issue. |
433
- | issue | ` String ` | The issue number. |
434
-
435
- #### parentOf
436
-
437
- Type: ` Array<Object> `
438
-
439
- List of child issues and pull requests.<br >
440
- Each action has the following properties:
441
-
442
- | Name | Type | Description |
443
- | --------| ----------| ---------------------------------------------------------------------------------------|
444
- | raw | ` String ` | The raw value parsed, for example ` Parent of #1 ` . |
445
- | action | ` String ` | The keyword used to identify the action, capitalized. |
446
- | slug | ` String ` | The repository owner and name, for issue referred as ` <owner>/<repo>#<issue number> ` . |
447
- | prefix | ` String ` | The prefix used to identify the issue. |
448
- | issue | ` String ` | The issue number. |
449
-
450
- #### childOf
451
-
452
- Type: ` Array<Object> `
453
-
454
- List of parent issues and pull requests.<br >
455
- Each action has the following properties:
456
-
457
- | Name | Type | Description |
458
- | --------| ----------| ---------------------------------------------------------------------------------------|
459
- | raw | ` String ` | The raw value parsed, for example ` Child of #1 ` . |
460
- | action | ` String ` | The keyword used to identify the action, capitalized. |
461
- | slug | ` String ` | The repository owner and name, for issue referred as ` <owner>/<repo>#<issue number> ` . |
462
- | prefix | ` String ` | The prefix used to identify the issue. |
463
- | issue | ` String ` | The issue number. |
464
-
465
- #### duplicates
466
-
467
- Type: ` Array<Object> `
468
-
469
- List of issues and pull requests marked as duplicate.<br >
470
- Each duplicate has the following properties:
471
-
472
- | Name | Type | Description |
473
- | --------| ----------| ---------------------------------------------------------------------------------------|
474
- | raw | ` String ` | The raw value parsed, for example ` Duplicate of #1 ` . |
475
- | action | ` String ` | The keyword used to identify the duplicate, capitalized. |
476
- | slug | ` String ` | The repository owner and name, for issue referred as ` <owner>/<repo>#<issue number> ` . |
477
- | prefix | ` String ` | The prefix used to identify the issue. |
478
- | issue | ` String ` | The issue number. |
479
-
480
411
#### refs
481
412
482
413
Type: ` Array<Object> `
483
414
484
- List of issues and pull requests referenced, but not closed or marked as duplicates .<br >
415
+ List of issues and pull requests referenced, but not matched with an action .<br >
485
416
Each reference has the following properties:
486
417
487
418
| Name | Type | Description |
@@ -508,13 +439,13 @@ Each mention has the following properties:
508
439
509
440
Type: ` Array<Object> `
510
441
511
- List of all issues and pull requests [ closed ] ( #actions ) , [ marked as duplicate ] ( #duplicates ) or [ referenced ] ( #refs ) .<br >
442
+ List of all issues and pull requests [ referenced ] ( #refs ) or matching an [ action ] ( #actions-1 ) .<br >
512
443
Each reference has the following properties:
513
444
514
- | Name | Type | Description |
515
- | --------| ----------| ---------------------------------------------------------------------------------------|
516
- | raw | ` String ` | The raw value parsed, for example ` Fix #1 ` . |
517
- | action | ` String ` | The keyword used to identify the action or the duplicate, capitalized. |
518
- | slug | ` String ` | The repository owner and name, for issue referred as ` <owner>/<repo>#<issue number> ` . |
519
- | prefix | ` String ` | The prefix used to identify the issue. |
520
- | issue | ` String ` | The issue number. |
445
+ | Name | Type | Description |
446
+ | --------| ----------| ------------------------------------------------------------------------------------------------------ |
447
+ | raw | ` String ` | The raw value parsed, for example ` Fix #1 ` . |
448
+ | action | ` String ` | The keyword used to identify the action or the duplicate, capitalized. Only if matched by an action. |
449
+ | slug | ` String ` | The repository owner and name, for issue referred as ` <owner>/<repo>#<issue number> ` . |
450
+ | prefix | ` String ` | The prefix used to identify the issue. |
451
+ | issue | ` String ` | The issue number. |
0 commit comments