File tree 4 files changed +62
-1
lines changed
4 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ class CML {
163
163
const triggerSha = await this . triggerSha ( ) ;
164
164
const {
165
165
commitSha : inCommitSha = triggerSha ,
166
- // issue: issueId,
166
+ issue : issueId ,
167
167
rmWatermark,
168
168
update,
169
169
pr,
@@ -267,6 +267,23 @@ class CML {
267
267
return body . includes ( 'watermark.svg' ) ;
268
268
} ) ;
269
269
} ;
270
+ // Create or update an issue comment.
271
+ if ( issueId ) {
272
+ if ( update ) {
273
+ comment = updatableComment ( await drv . issueComments ( { issueId } ) ) ;
274
+
275
+ if ( comment )
276
+ return await drv . issueCommentUpdate ( {
277
+ report,
278
+ id : comment . id ,
279
+ issueId
280
+ } ) ;
281
+ }
282
+ return await drv . issueCommentCreate ( {
283
+ report,
284
+ issueId
285
+ } ) ;
286
+ }
270
287
271
288
const isBB = this . driver === BB ;
272
289
if ( pr || isBB ) {
Original file line number Diff line number Diff line change @@ -56,6 +56,18 @@ class BitbucketCloud {
56
56
) . links . html . href ;
57
57
}
58
58
59
+ async issueComments ( opts = { } ) {
60
+ const { projectPath } = this ;
61
+ const { issueId } = opts ;
62
+
63
+ const endpoint = `/repositories/${ projectPath } /issues/${ issueId } /comments/` ;
64
+ return ( await this . paginatedRequest ( { endpoint, method : 'GET' } ) ) . map (
65
+ ( { id, content : { raw : body = '' } = { } } ) => {
66
+ return { id, body } ;
67
+ }
68
+ ) ;
69
+ }
70
+
59
71
async commentCreate ( opts = { } ) {
60
72
const { projectPath } = this ;
61
73
const { commitSha, report } = opts ;
Original file line number Diff line number Diff line change @@ -574,6 +574,22 @@ class Github {
574
574
return htmlUrl ;
575
575
}
576
576
577
+ async issueComments ( opts = { } ) {
578
+ const { issueId } = opts ;
579
+ const { owner, repo } = ownerRepo ( { uri : this . repo } ) ;
580
+ const { issues } = octokit ( this . token , this . repo ) ;
581
+
582
+ const { data : comments } = await issues . listComments ( {
583
+ owner,
584
+ repo,
585
+ issue_number : issueId
586
+ } ) ;
587
+
588
+ return comments . map ( ( { id, body } ) => {
589
+ return { id, body } ;
590
+ } ) ;
591
+ }
592
+
577
593
async prCommentCreate ( opts = { } ) {
578
594
const { report : body , prNumber } = opts ;
579
595
const { owner, repo } = ownerRepo ( { uri : this . repo } ) ;
Original file line number Diff line number Diff line change @@ -363,6 +363,22 @@ class Gitlab {
363
363
return `${ this . repo } /-/issues/${ issueId } #note_${ id } ` ;
364
364
}
365
365
366
+ async issueComments ( opts = { } ) {
367
+ const projectPath = await this . projectPath ( ) ;
368
+ const { issueId } = opts ;
369
+
370
+ const endpoint = `/projects/${ projectPath } /issues/${ issueId } /notes` ;
371
+
372
+ const comments = await this . request ( {
373
+ endpoint,
374
+ method : 'GET'
375
+ } ) ;
376
+
377
+ return comments . map ( ( { id, body } ) => {
378
+ return { id, body } ;
379
+ } ) ;
380
+ }
381
+
366
382
async prCommentCreate ( opts = { } ) {
367
383
const projectPath = await this . projectPath ( ) ;
368
384
const { report, prNumber } = opts ;
You can’t perform that action at this time.
0 commit comments