@@ -4,12 +4,12 @@ const CLOSING_SYNTAX_PATTERNS = [
4
4
/ (?: (?: c l o s e | f i x e | r e s o l v e ) [ s d ] ? | f i x ) \s + (?: m l f l o w \/ m l f l o w ) ? # ( \d + ) / gi,
5
5
/ (?: (?: c l o s e | f i x e | r e s o l v e ) [ s d ] ? | f i x ) \s + (?: h t t p s ? : \/ \/ g i t h u b .c o m \/ m l f l o w \/ m l f l o w \/ i s s u e s \/ ) ( \d + ) / gi,
6
6
] ;
7
- const HAS_CLOSING_PR_LABEL = ' has-closing-pr' ;
7
+ const HAS_CLOSING_PR_LABEL = " has-closing-pr" ;
8
8
9
9
const getIssuesToClose = ( body ) => {
10
- const commentsExcluded = body . replace ( / < ! - - ( .+ ?) - - > / gs, '' ) ; // remove comments
10
+ const commentsExcluded = body . replace ( / < ! - - ( .+ ?) - - > / gs, "" ) ; // remove comments
11
11
const matches = CLOSING_SYNTAX_PATTERNS . flatMap ( ( pattern ) =>
12
- Array . from ( commentsExcluded . matchAll ( pattern ) ) ,
12
+ Array . from ( commentsExcluded . matchAll ( pattern ) )
13
13
) ;
14
14
const issueNumbers = matches . map ( ( match ) => match [ 1 ] ) ;
15
15
return [ ...new Set ( issueNumbers ) ] . sort ( ) ;
@@ -30,32 +30,32 @@ const capitalizeFirstLetter = (string) => {
30
30
} ;
31
31
32
32
const test = ( ) => {
33
- [ ' close' , ' closes' , ' closed' , ' fix' , ' fixes' , ' fixed' , ' resolve' , ' resolves' , ' resolved' ] . forEach (
33
+ [ " close" , " closes" , " closed" , " fix" , " fixes" , " fixed" , " resolve" , " resolves" , " resolved" ] . forEach (
34
34
( keyword ) => {
35
- assertArrayEqual ( getIssuesToClose ( `${ keyword } #123` ) , [ ' 123' ] ) ;
36
- assertArrayEqual ( getIssuesToClose ( `${ capitalizeFirstLetter ( keyword ) } #123` ) , [ ' 123' ] ) ;
37
- } ,
35
+ assertArrayEqual ( getIssuesToClose ( `${ keyword } #123` ) , [ " 123" ] ) ;
36
+ assertArrayEqual ( getIssuesToClose ( `${ capitalizeFirstLetter ( keyword ) } #123` ) , [ " 123" ] ) ;
37
+ }
38
38
) ;
39
39
40
40
const body2 = `
41
41
Fix mlflow/mlflow#123
42
42
Resolve https://github.com/mlflow/mlflow/issues/456
43
43
` ;
44
- assertArrayEqual ( getIssuesToClose ( body2 ) , [ ' 123' , ' 456' ] ) ;
44
+ assertArrayEqual ( getIssuesToClose ( body2 ) , [ " 123" , " 456" ] ) ;
45
45
46
46
const body3 = `
47
47
Fix #123
48
48
Close #123
49
49
` ;
50
- assertArrayEqual ( getIssuesToClose ( body3 ) , [ ' 123' ] ) ;
50
+ assertArrayEqual ( getIssuesToClose ( body3 ) , [ " 123" ] ) ;
51
51
52
- const body4 = ' Relates to #123' ;
52
+ const body4 = " Relates to #123" ;
53
53
assertArrayEqual ( getIssuesToClose ( body4 ) , [ ] ) ;
54
54
55
- const body5 = ' <!-- close #123 -->' ;
55
+ const body5 = " <!-- close #123 -->" ;
56
56
assertArrayEqual ( getIssuesToClose ( body5 ) , [ ] ) ;
57
57
58
- const body6 = ' Fixs #123 Fixd #456' ;
58
+ const body6 = " Fixs #123 Fixd #456" ;
59
59
assertArrayEqual ( getIssuesToClose ( body6 ) , [ ] ) ;
60
60
} ;
61
61
@@ -66,7 +66,7 @@ if (require.main === module) {
66
66
67
67
module . exports = async ( { context, github } ) => {
68
68
const { body } = context . payload . pull_request ;
69
- getIssuesToClose ( body || '' ) . forEach ( async ( issue_number ) => {
69
+ getIssuesToClose ( body || "" ) . forEach ( async ( issue_number ) => {
70
70
const { owner, repo } = context . repo ;
71
71
await github . rest . issues . addLabels ( {
72
72
owner,
0 commit comments