@@ -349,40 +349,20 @@ export class GitHub {
349
349
return repositoryActivities
350
350
}
351
351
352
- async listRepositoryPullRequests ( since : Date ) {
353
- const repositoryPullRequests = [ ]
354
- const repositories = await this . listRepositories ( )
355
- for ( const repository of repositories ) {
356
- core . info ( `Listing ${ repository . name } pull requests...` )
357
- const pullRequestsIterator = this . client . paginate . iterator (
358
- this . client . pulls . list ,
359
- { owner : env . GITHUB_ORG , repo : repository . name , state : 'all' }
360
- )
361
- for await ( const { data : pullRequests } of pullRequestsIterator ) {
362
- let shouldContinue = true
363
- for ( const pullRequest of pullRequests ) {
364
- if ( new Date ( pullRequest . created_at ) < since ) {
365
- shouldContinue = false
366
- break
367
- }
368
- repositoryPullRequests . push ( { repository, pullRequest} )
369
- }
370
- if ( ! shouldContinue ) {
371
- break
372
- }
373
- }
374
- }
375
- return repositoryPullRequests
376
- }
377
-
378
352
async listRepositoryIssues ( since : Date ) {
379
353
const issues = [ ]
380
354
const repositories = await this . listRepositories ( )
381
355
for ( const repository of repositories ) {
382
356
core . info ( `Listing ${ repository . name } issues...` )
383
357
const issuesIterator = this . client . paginate . iterator (
384
358
this . client . issues . listForRepo ,
385
- { owner : env . GITHUB_ORG , repo : repository . name , state : 'all' }
359
+ {
360
+ owner : env . GITHUB_ORG ,
361
+ repo : repository . name ,
362
+ state : 'all' ,
363
+ sort : 'created' ,
364
+ direction : 'desc'
365
+ }
386
366
)
387
367
for await ( const { data : issuesData } of issuesIterator ) {
388
368
let shouldContinue = true
@@ -408,7 +388,7 @@ export class GitHub {
408
388
core . info ( `Listing ${ repository . name } pull request comments...` )
409
389
const pullRequestCommentsIterator = this . client . paginate . iterator (
410
390
this . client . pulls . listReviewCommentsForRepo ,
411
- { owner : env . GITHUB_ORG , repo : repository . name }
391
+ { owner : env . GITHUB_ORG , repo : repository . name , direction : 'desc' }
412
392
)
413
393
for await ( const { data : comments } of pullRequestCommentsIterator ) {
414
394
let shouldContinue = true
@@ -434,7 +414,12 @@ export class GitHub {
434
414
core . info ( `Listing ${ repository . name } issue comments...` )
435
415
const issueCommentsIterator = this . client . paginate . iterator (
436
416
this . client . issues . listCommentsForRepo ,
437
- { owner : env . GITHUB_ORG , repo : repository . name }
417
+ {
418
+ owner : env . GITHUB_ORG ,
419
+ repo : repository . name ,
420
+ sort : 'created' ,
421
+ direction : 'desc'
422
+ }
438
423
)
439
424
for await ( const { data : comments } of issueCommentsIterator ) {
440
425
let shouldContinue = true
@@ -458,22 +443,14 @@ export class GitHub {
458
443
const repositories = await this . listRepositories ( )
459
444
for ( const repository of repositories ) {
460
445
core . info ( `Listing ${ repository . name } commit comments...` )
461
- const commitCommentsIterator = this . client . paginate . iterator (
446
+ const comments = await this . client . paginate (
462
447
this . client . repos . listCommitCommentsForRepo ,
463
448
{ owner : env . GITHUB_ORG , repo : repository . name }
464
449
)
465
- for await ( const { data : comments } of commitCommentsIterator ) {
466
- let shouldContinue = true
467
- for ( const comment of comments ) {
468
- if ( new Date ( comment . created_at ) < since ) {
469
- shouldContinue = false
470
- break
471
- }
450
+ for ( const comment of comments ) {
451
+ if ( new Date ( comment . created_at ) >= since ) {
472
452
commitComments . push ( { repository, comment} )
473
453
}
474
- if ( ! shouldContinue ) {
475
- break
476
- }
477
454
}
478
455
}
479
456
return commitComments
0 commit comments