@@ -11,6 +11,7 @@ The parser can identify:
1111- 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 )
1212- 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 )
1313- 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
1415
1516## Install
1617
@@ -30,8 +31,10 @@ parse('Issue description, ref user/package#1, Fix #2, Duplicate of #3 /cc @user'
3031/*
3132{
3233 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+ },
3538 mentions: [{raw: '@user', prefix: '@', user: 'user'}],
3639}
3740*/
@@ -50,8 +53,10 @@ parse('Issue description, ref group/user/package#1, !2, implement #3, /duplicate
5053 {raw: 'group/user/package#1', slug: 'group/user/package', prefix: '#', issue: '1'},
5154 {raw: '!2', slug: 'group/user/package', prefix: '!', issue: '2'},
5255 ],
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+ },
5560 mentions: [{raw: '@user', prefix: '@', user: 'user'}],
5661}
5762*/
@@ -67,7 +72,9 @@ parse('Issue description, ref user/package#1, fixing #2. /cc @user');
6772/*
6873{
6974 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+ },
7178 mentions: [{raw: '@user', prefix: '@', user: 'user'}],
7279}
7380*/
@@ -83,11 +90,13 @@ parse('Issue description, ref user/package#1, Fix #2, blocks user/package#3, Req
8390/*
8491{
8592 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+ },
91100 mentions: [{raw: '@user', prefix: '@', user: 'user'}],
92101}
93102*/
@@ -97,14 +106,36 @@ parse('Issue description, ref user/package#1, Fix #2, blocks user/package#3, Req
97106
98107``` js
99108const 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: [' 🐛' ]});
101110
102111parse (' Issue description, related to user/package🐛1, Complete 🐛2, holds up 🐛3' );
103112/*
104113{
105114 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'}],
108139}
109140*/
110141```
@@ -135,7 +166,7 @@ owner/repo#1
135166Fix #1
136167```
137168``` 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' }]} }
139170```
140171
141172### Parse duplicate keywords
@@ -144,7 +175,7 @@ Fix #1
144175Duplicate of #1
145176```
146177``` 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' }]} }
148179```
149180
150181### Parse user mentions
@@ -166,9 +197,11 @@ Fix https://github.com/owner/repo/issues/2
166197``` js
167198{
168199 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+ }
172205}
173206```
174207
@@ -178,7 +211,7 @@ Fix https://github.com/owner/repo/issues/2
178211FIX #1
179212```
180213``` 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' }]} }
182215```
183216
184217### Ignore references in back-tick quotes
@@ -188,7 +221,7 @@ Fix #1 `Fix #2` @user1 `@user2`
188221```
189222``` js
190223{
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' }]} ,
192225 mentions: [{raw: ' @user1' , prefix: ' @' , user: ' user1' }]
193226}
194227```
@@ -200,7 +233,7 @@ Fix #1 `Fix #2` @user1 `@user2`
200233```
201234``` js
202235{
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' }]} ,
204237 mentions: [{raw: ' @user1' , prefix: ' @' , user: ' user1' }]
205238}
206239```
@@ -222,7 +255,7 @@ console.log('@user2');
222255````
223256``` js
224257{
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' }]} ,
226259 mentions: [{raw: ' @user1' , prefix: ' @' , user: ' user1' }]
227260}
228261```
@@ -240,7 +273,7 @@ Fix #1
240273```
241274``` js
242275{
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' }]} ,
244277 mentions: [{raw: ' @user' , prefix: ' @' , user: ' user' }]
245278}
246279```
@@ -256,7 +289,7 @@ Fix #1
256289```
257290``` js
258291{
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' }]} ,
260293 mentions: [{raw: ' @user1' , prefix: ' @' , user: ' user1' }]
261294}
262295```
@@ -269,7 +302,7 @@ Fix #1
269302```
270303``` js
271304{
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' }]} ,
273306 mentions: [{raw: ' @user' , prefix: ' @' , user: ' user' }]
274307}
275308```
@@ -280,7 +313,7 @@ Fix #1
280313Fix #1 Fix #2a Fix a#3
281314```
282315``` 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' }]} }
284317```
285318
286319## API
@@ -294,47 +327,20 @@ Create a [parser](#parsetext--result).
294327Type: ` Object ` ` String ` <br >
295328Parser options. Can be ` github ` , ` gitlab ` or ` bitbucket ` for predefined options, or an object for custom options.
296329
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
319331
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'] }`
333340
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.
336342
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 ` .
338344
339345##### mentionsPrefixes
340346
@@ -389,10 +395,10 @@ Issue text to parse.
389395
390396#### actions
391397
392- Type: ` Array< Object> `
398+ Type: ` Object `
393399
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:
396402
397403| Name | Type | Description |
398404| --------| ----------| ---------------------------------------------------------------------------------------|
@@ -402,86 +408,11 @@ Each action has the following properties:
402408| prefix | ` String ` | The prefix used to identify the issue. |
403409| issue | ` String ` | The issue number. |
404410
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-
480411#### refs
481412
482413Type: ` Array<Object> `
483414
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 >
485416Each reference has the following properties:
486417
487418| Name | Type | Description |
@@ -508,13 +439,13 @@ Each mention has the following properties:
508439
509440Type: ` Array<Object> `
510441
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 >
512443Each reference has the following properties:
513444
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