@@ -56,7 +56,7 @@ test.serial('Add comment to PRs associated with release commits and issues close
56
56
const commits = [
57
57
{ hash : '123' , message : 'Commit 1 message\n\n Fix #1' , tree : { long : 'aaa' } } ,
58
58
{ hash : '456' , message : 'Commit 2 message' , tree : { long : 'ccc' } } ,
59
- { hash : '789' , message : ' Commit 3 message Closes #4' , tree : { long : 'ccc' } } ,
59
+ { hash : '789' , message : ` Commit 3 message Closes https://github.com/ ${ owner } / ${ repo } /issues/4` , tree : { long : 'ccc' } } ,
60
60
] ;
61
61
const nextRelease = { version : '1.0.0' } ;
62
62
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
@@ -99,6 +99,72 @@ test.serial('Add comment to PRs associated with release commits and issues close
99
99
t . true ( github . isDone ( ) ) ;
100
100
} ) ;
101
101
102
+ test . serial (
103
+ 'Add comment to PRs associated with release commits and issues closed by PR/commits comments with custom URL' ,
104
+ async t => {
105
+ const owner = 'test_user' ;
106
+ const repo = 'test_repo' ;
107
+ process . env . GH_URL = 'https://custom-url.com' ;
108
+ process . env . GH_TOKEN = 'github_token' ;
109
+ process . env . GH_PREFIX = 'prefix' ;
110
+ const failTitle = 'The automated release is failing 🚨' ;
111
+ const pluginConfig = { failTitle} ;
112
+ const prs = [
113
+ { number : 1 , pull_request : { } , state : 'closed' } ,
114
+ { number : 2 , pull_request : { } , body : 'Fixes #3' , state : 'closed' } ,
115
+ ] ;
116
+ const options = { branch : 'master' , repositoryUrl : `https://custom-url.com/${ owner } /${ repo } .git` } ;
117
+ const commits = [
118
+ { hash : '123' , message : 'Commit 1 message\n\n Fix #1' , tree : { long : 'aaa' } } ,
119
+ { hash : '456' , message : 'Commit 2 message' , tree : { long : 'ccc' } } ,
120
+ {
121
+ hash : '789' ,
122
+ message : `Commit 3 message Closes https://custom-url.com/${ owner } /${ repo } /issues/4` ,
123
+ tree : { long : 'ccc' } ,
124
+ } ,
125
+ ] ;
126
+ const nextRelease = { version : '1.0.0' } ;
127
+ const releases = [ { name : 'GitHub release' , url : 'https://custom-url.com/release' } ] ;
128
+ const github = authenticate ( )
129
+ . get (
130
+ `/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
131
+ . map ( commit => commit . hash )
132
+ . join ( '+' ) } `
133
+ )
134
+ . reply ( 200 , { items : prs } )
135
+ . get ( `/repos/${ owner } /${ repo } /pulls/1/commits` )
136
+ . reply ( 200 , [ { sha : commits [ 0 ] . hash } ] )
137
+ . get ( `/repos/${ owner } /${ repo } /pulls/2/commits` )
138
+ . reply ( 200 , [ { sha : commits [ 1 ] . hash } ] )
139
+ . post ( `/repos/${ owner } /${ repo } /issues/1/comments` , { body : / T h i s P R i s i n c l u d e d / } )
140
+ . reply ( 200 , { html_url : 'https://custom-url.com/successcomment-1' } )
141
+ . post ( `/repos/${ owner } /${ repo } /issues/2/comments` , { body : / T h i s P R i s i n c l u d e d / } )
142
+ . reply ( 200 , { html_url : 'https://custom-url.com/successcomment-2' } )
143
+ . get ( `/repos/${ owner } /${ repo } /issues/3` )
144
+ . reply ( 200 , { state : 'closed' } )
145
+ . post ( `/repos/${ owner } /${ repo } /issues/3/comments` , { body : / T h i s i s s u e h a s b e e n r e s o l v e d / } )
146
+ . reply ( 200 , { html_url : 'https://custom-url.com/successcomment-3' } )
147
+ . get ( `/repos/${ owner } /${ repo } /issues/4` )
148
+ . reply ( 200 , { state : 'closed' } )
149
+ . post ( `/repos/${ owner } /${ repo } /issues/4/comments` , { body : / T h i s i s s u e h a s b e e n r e s o l v e d / } )
150
+ . reply ( 200 , { html_url : 'https://custom-url.com/successcomment-4' } )
151
+ . get (
152
+ `/search/issues?q=${ escape ( 'in:title' ) } +${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:issue' ) } +${ escape (
153
+ 'state:open'
154
+ ) } +${ escape ( failTitle ) } `
155
+ )
156
+ . reply ( 200 , { items : [ ] } ) ;
157
+
158
+ await success ( pluginConfig , { options, commits, nextRelease, releases, logger : t . context . logger } ) ;
159
+
160
+ t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 1 , 'https://custom-url.com/successcomment-1' ) ) ;
161
+ t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 2 , 'https://custom-url.com/successcomment-2' ) ) ;
162
+ t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 3 , 'https://custom-url.com/successcomment-3' ) ) ;
163
+ t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 4 , 'https://custom-url.com/successcomment-4' ) ) ;
164
+ t . true ( github . isDone ( ) ) ;
165
+ }
166
+ ) ;
167
+
102
168
test . serial ( 'Make multiple search queries if necessary' , async t => {
103
169
const owner = 'test_user' ;
104
170
const repo = 'test_repo' ;
0 commit comments