@@ -459,49 +459,48 @@ func (g *GiteaDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, err
459
459
func (g * GiteaDownloader ) GetComments (opts base.GetCommentOptions ) ([]* base.Comment , bool , error ) {
460
460
var allComments = make ([]* base.Comment , 0 , g .maxPerPage )
461
461
462
- // for i := 1; ; i++ {
463
- // make sure gitea can shutdown gracefully
464
- select {
465
- case <- g .ctx .Done ():
466
- return nil , false , nil
467
- default :
468
- }
469
-
470
- comments , _ , err := g .client .ListIssueComments (g .repoOwner , g .repoName , opts .Context .ForeignID (), gitea_sdk.ListIssueCommentOptions {ListOptions : gitea_sdk.ListOptions {
471
- // PageSize: g.maxPerPage,
472
- // Page: i,
473
- }})
474
- if err != nil {
475
- return nil , false , fmt .Errorf ("error while listing comments for issue #%d. Error: %v" , opts .Context .ForeignID (), err )
476
- }
462
+ for i := 1 ; ; i ++ {
463
+ // make sure gitea can shutdown gracefully
464
+ select {
465
+ case <- g .ctx .Done ():
466
+ return nil , false , nil
467
+ default :
468
+ }
477
469
478
- for _ , comment := range comments {
479
- reactions , err := g .getCommentReactions (comment .ID )
470
+ comments , _ , err := g .client .ListIssueComments (g .repoOwner , g .repoName , opts .Context .ForeignID (), gitea_sdk.ListIssueCommentOptions {ListOptions : gitea_sdk.ListOptions {
471
+ PageSize : g .maxPerPage ,
472
+ Page : i ,
473
+ }})
480
474
if err != nil {
481
- log .Warn ("Unable to load comment reactions during migrating issue #%d for comment %d to %s/%s. Error: %v" , opts .Context .ForeignID (), comment .ID , g .repoOwner , g .repoName , err )
482
- if err2 := models .CreateRepositoryNotice (
483
- fmt .Sprintf ("Unable to load reactions during migrating issue #%d for comment %d to %s/%s. Error: %v" , opts .Context .ForeignID (), comment .ID , g .repoOwner , g .repoName , err )); err2 != nil {
484
- log .Error ("create repository notice failed: " , err2 )
475
+ return nil , false , fmt .Errorf ("error while listing comments for issue #%d. Error: %v" , opts .Context .ForeignID (), err )
476
+ }
477
+
478
+ for _ , comment := range comments {
479
+ reactions , err := g .getCommentReactions (comment .ID )
480
+ if err != nil {
481
+ log .Warn ("Unable to load comment reactions during migrating issue #%d for comment %d to %s/%s. Error: %v" , opts .Context .ForeignID (), comment .ID , g .repoOwner , g .repoName , err )
482
+ if err2 := models .CreateRepositoryNotice (
483
+ fmt .Sprintf ("Unable to load reactions during migrating issue #%d for comment %d to %s/%s. Error: %v" , opts .Context .ForeignID (), comment .ID , g .repoOwner , g .repoName , err )); err2 != nil {
484
+ log .Error ("create repository notice failed: " , err2 )
485
+ }
485
486
}
487
+
488
+ allComments = append (allComments , & base.Comment {
489
+ IssueIndex : opts .Context .LocalID (),
490
+ PosterID : comment .Poster .ID ,
491
+ PosterName : comment .Poster .UserName ,
492
+ PosterEmail : comment .Poster .Email ,
493
+ Content : comment .Body ,
494
+ Created : comment .Created ,
495
+ Updated : comment .Updated ,
496
+ Reactions : reactions ,
497
+ })
486
498
}
487
499
488
- allComments = append (allComments , & base.Comment {
489
- IssueIndex : opts .Context .LocalID (),
490
- PosterID : comment .Poster .ID ,
491
- PosterName : comment .Poster .UserName ,
492
- PosterEmail : comment .Poster .Email ,
493
- Content : comment .Body ,
494
- Created : comment .Created ,
495
- Updated : comment .Updated ,
496
- Reactions : reactions ,
497
- })
500
+ if ! g .pagination || len (comments ) < g .maxPerPage {
501
+ break
502
+ }
498
503
}
499
-
500
- // TODO enable pagination vor (gitea >= 1.14) when it got implemented
501
- // if !g.pagination || len(comments) < g.maxPerPage {
502
- // break
503
- // }
504
- //}
505
504
return allComments , true , nil
506
505
}
507
506
0 commit comments