@@ -56,7 +56,7 @@ test.serial('Add comment to PRs associated with release commits and issues close
5656 const commits = [
5757 { hash : '123' , message : 'Commit 1 message\n\n Fix #1' , tree : { long : 'aaa' } } ,
5858 { 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' } } ,
6060 ] ;
6161 const nextRelease = { version : '1.0.0' } ;
6262 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
9999 t . true ( github . isDone ( ) ) ;
100100} ) ;
101101
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+
102168test . serial ( 'Make multiple search queries if necessary' , async t => {
103169 const owner = 'test_user' ;
104170 const repo = 'test_repo' ;
0 commit comments