@@ -31,6 +31,8 @@ test.serial(
31
31
async t => {
32
32
const owner = 'test_user' ;
33
33
const repo = 'test_repo' ;
34
+ const redirectedOwner = 'test_user_2' ;
35
+ const redirectedRepo = 'test_repo_2' ;
34
36
const env = { GITHUB_TOKEN : 'github_token' } ;
35
37
const failTitle = 'The automated release is failing 🚨' ;
36
38
const pluginConfig = { failTitle} ;
@@ -44,47 +46,49 @@ test.serial(
44
46
{ hash : '456' , message : 'Commit 2 message' , tree : { long : 'ccc' } } ,
45
47
{
46
48
hash : '789' ,
47
- message : `Commit 3 message Closes https://github.com/${ owner } /${ repo } /issues/4` ,
49
+ message : `Commit 3 message Closes https://github.com/${ redirectedOwner } /${ redirectedRepo } /issues/4` ,
48
50
tree : { long : 'ccc' } ,
49
51
} ,
50
52
] ;
51
53
const nextRelease = { version : '1.0.0' } ;
52
54
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
53
55
const github = authenticate ( env )
56
+ . get ( `/repos/${ owner } /${ repo } ` )
57
+ . reply ( 200 , { full_name : `${ redirectedOwner } /${ redirectedRepo } ` } )
54
58
. get (
55
- `/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } + ${ commits
56
- . map ( commit => commit . hash )
57
- . join ( '+' ) } `
59
+ `/search/issues?q=${ escape ( `repo:${ redirectedOwner } /${ redirectedRepo } ` ) } +${ escape ( 'type:pr' ) } +${ escape (
60
+ 'is:merged'
61
+ ) } + ${ commits . map ( commit => commit . hash ) . join ( '+' ) } `
58
62
)
59
63
. reply ( 200 , { items : prs } )
60
- . get ( `/repos/${ owner } /${ repo } /pulls/1/commits` )
64
+ . get ( `/repos/${ redirectedOwner } /${ redirectedRepo } /pulls/1/commits` )
61
65
. reply ( 200 , [ { sha : commits [ 0 ] . hash } ] )
62
- . get ( `/repos/${ owner } /${ repo } /pulls/2/commits` )
66
+ . get ( `/repos/${ redirectedOwner } /${ redirectedRepo } /pulls/2/commits` )
63
67
. reply ( 200 , [ { sha : commits [ 1 ] . hash } ] )
64
- . post ( `/repos/${ owner } /${ repo } /issues/1/comments` , { body : / T h i s P R i s i n c l u d e d / } )
68
+ . post ( `/repos/${ redirectedOwner } /${ redirectedRepo } /issues/1/comments` , { body : / T h i s P R i s i n c l u d e d / } )
65
69
. reply ( 200 , { html_url : 'https://github.com/successcomment-1' } )
66
- . post ( `/repos/${ owner } /${ repo } /issues/1/labels` , '["released"]' )
70
+ . post ( `/repos/${ redirectedOwner } /${ redirectedRepo } /issues/1/labels` , '["released"]' )
67
71
. reply ( 200 , { } )
68
- . post ( `/repos/${ owner } /${ repo } /issues/2/comments` , { body : / T h i s P R i s i n c l u d e d / } )
72
+ . post ( `/repos/${ redirectedOwner } /${ redirectedRepo } /issues/2/comments` , { body : / T h i s P R i s i n c l u d e d / } )
69
73
. reply ( 200 , { html_url : 'https://github.com/successcomment-2' } )
70
- . post ( `/repos/${ owner } /${ repo } /issues/2/labels` , '["released"]' )
74
+ . post ( `/repos/${ redirectedOwner } /${ redirectedRepo } /issues/2/labels` , '["released"]' )
71
75
. reply ( 200 , { } )
72
- . get ( `/repos/${ owner } /${ repo } /issues/3` )
76
+ . get ( `/repos/${ redirectedOwner } /${ redirectedRepo } /issues/3` )
73
77
. reply ( 200 , { state : 'closed' } )
74
- . 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 / } )
78
+ . post ( `/repos/${ redirectedOwner } /${ redirectedRepo } /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 / } )
75
79
. reply ( 200 , { html_url : 'https://github.com/successcomment-3' } )
76
- . post ( `/repos/${ owner } /${ repo } /issues/3/labels` , '["released"]' )
80
+ . post ( `/repos/${ redirectedOwner } /${ redirectedRepo } /issues/3/labels` , '["released"]' )
77
81
. reply ( 200 , { } )
78
- . get ( `/repos/${ owner } /${ repo } /issues/4` )
82
+ . get ( `/repos/${ redirectedOwner } /${ redirectedRepo } /issues/4` )
79
83
. reply ( 200 , { state : 'closed' } )
80
- . 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 / } )
84
+ . post ( `/repos/${ redirectedOwner } /${ redirectedRepo } /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 / } )
81
85
. reply ( 200 , { html_url : 'https://github.com/successcomment-4' } )
82
- . post ( `/repos/${ owner } /${ repo } /issues/4/labels` , '["released"]' )
86
+ . post ( `/repos/${ redirectedOwner } /${ redirectedRepo } /issues/4/labels` , '["released"]' )
83
87
. reply ( 200 , { } )
84
88
. get (
85
- `/search/issues?q=${ escape ( 'in:title' ) } +${ escape ( `repo:${ owner } /${ repo } ` ) } + ${ escape ( 'type:issue' ) } +${ escape (
86
- 'state:open '
87
- ) } +${ escape ( failTitle ) } `
89
+ `/search/issues?q=${ escape ( 'in:title' ) } +${ escape ( `repo:${ redirectedOwner } /${ redirectedRepo } ` ) } +${ escape (
90
+ 'type:issue '
91
+ ) } +${ escape ( 'state:open' ) } + ${ escape ( failTitle ) } `
88
92
)
89
93
. reply ( 200 , { items : [ ] } ) ;
90
94
@@ -123,6 +127,8 @@ test.serial(
123
127
const nextRelease = { version : '1.0.0' } ;
124
128
const releases = [ { name : 'GitHub release' , url : 'https://custom-url.com/release' } ] ;
125
129
const github = authenticate ( env )
130
+ . get ( `/repos/${ owner } /${ repo } ` )
131
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
126
132
. get (
127
133
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
128
134
. map ( commit => commit . hash )
@@ -201,6 +207,8 @@ test.serial('Make multiple search queries if necessary', async t => {
201
207
const nextRelease = { version : '1.0.0' } ;
202
208
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
203
209
const github = authenticate ( env )
210
+ . get ( `/repos/${ owner } /${ repo } ` )
211
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
204
212
. get (
205
213
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${
206
214
commits [ 0 ] . hash
@@ -287,6 +295,8 @@ test.serial(
287
295
const nextRelease = { version : '1.0.0' } ;
288
296
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
289
297
const github = authenticate ( env )
298
+ . get ( `/repos/${ owner } /${ repo } ` )
299
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
290
300
. get (
291
301
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
292
302
. map ( commit => commit . hash )
@@ -332,6 +342,8 @@ test.serial('Do not add comment and labels to open issues/PRs', async t => {
332
342
const nextRelease = { version : '1.0.0' } ;
333
343
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
334
344
const github = authenticate ( env )
345
+ . get ( `/repos/${ owner } /${ repo } ` )
346
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
335
347
. get (
336
348
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
337
349
. map ( commit => commit . hash )
@@ -372,6 +384,8 @@ test.serial('Do not add comment and labels if no PR is associated with release c
372
384
const nextRelease = { version : '1.0.0' } ;
373
385
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
374
386
const github = authenticate ( env )
387
+ . get ( `/repos/${ owner } /${ repo } ` )
388
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
375
389
. get (
376
390
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
377
391
. map ( commit => commit . hash )
@@ -405,6 +419,8 @@ test.serial('Do not add comment and labels to PR/issues from other repo', async
405
419
const nextRelease = { version : '1.0.0' } ;
406
420
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
407
421
const github = authenticate ( env )
422
+ . get ( `/repos/${ owner } /${ repo } ` )
423
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
408
424
. get (
409
425
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
410
426
. map ( commit => commit . hash )
@@ -446,6 +462,8 @@ test.serial('Ignore missing issues/PRs', async t => {
446
462
const nextRelease = { version : '1.0.0' } ;
447
463
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
448
464
const github = authenticate ( env )
465
+ . get ( `/repos/${ owner } /${ repo } ` )
466
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
449
467
. get (
450
468
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
451
469
. map ( commit => commit . hash )
@@ -502,6 +520,8 @@ test.serial('Add custom comment', async t => {
502
520
const nextRelease = { version : '2.0.0' } ;
503
521
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
504
522
const github = authenticate ( env )
523
+ . get ( `/repos/${ owner } /${ repo } ` )
524
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
505
525
. get (
506
526
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
507
527
. map ( commit => commit . hash )
@@ -543,6 +563,8 @@ test.serial('Add custom label', async t => {
543
563
const nextRelease = { version : '2.0.0' } ;
544
564
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
545
565
const github = authenticate ( env )
566
+ . get ( `/repos/${ owner } /${ repo } ` )
567
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
546
568
. get (
547
569
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
548
570
. map ( commit => commit . hash )
@@ -582,6 +604,8 @@ test.serial('Comment on issue/PR without ading a label', async t => {
582
604
const nextRelease = { version : '2.0.0' } ;
583
605
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
584
606
const github = authenticate ( env )
607
+ . get ( `/repos/${ owner } /${ repo } ` )
608
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
585
609
. get (
586
610
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
587
611
. map ( commit => commit . hash )
@@ -622,6 +646,8 @@ test.serial('Ignore errors when adding comments and closing issues', async t =>
622
646
const nextRelease = { version : '1.0.0' } ;
623
647
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
624
648
const github = authenticate ( env )
649
+ . get ( `/repos/${ owner } /${ repo } ` )
650
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
625
651
. get (
626
652
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
627
653
. map ( commit => commit . hash )
@@ -677,6 +703,8 @@ test.serial('Close open issues when a release is successful', async t => {
677
703
const nextRelease = { version : '1.0.0' } ;
678
704
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
679
705
const github = authenticate ( env )
706
+ . get ( `/repos/${ owner } /${ repo } ` )
707
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
680
708
. get (
681
709
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
682
710
. map ( commit => commit . hash )
@@ -712,6 +740,8 @@ test.serial('Skip commention on issues/PR if "successComment" is "false"', async
712
740
const nextRelease = { version : '1.0.0' } ;
713
741
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
714
742
const github = authenticate ( env )
743
+ . get ( `/repos/${ owner } /${ repo } ` )
744
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
715
745
. get (
716
746
`/search/issues?q=${ escape ( 'in:title' ) } +${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:issue' ) } +${ escape (
717
747
'state:open'
@@ -735,6 +765,8 @@ test.serial('Skip closing issues if "failComment" is "false"', async t => {
735
765
const nextRelease = { version : '1.0.0' } ;
736
766
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
737
767
const github = authenticate ( env )
768
+ . get ( `/repos/${ owner } /${ repo } ` )
769
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
738
770
. get (
739
771
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
740
772
. map ( commit => commit . hash )
@@ -757,6 +789,8 @@ test.serial('Skip closing issues if "failTitle" is "false"', async t => {
757
789
const nextRelease = { version : '1.0.0' } ;
758
790
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
759
791
const github = authenticate ( env )
792
+ . get ( `/repos/${ owner } /${ repo } ` )
793
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
760
794
. get (
761
795
`/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
762
796
. map ( commit => commit . hash )
0 commit comments