@@ -631,9 +631,33 @@ func convertGithubReview(r *github.PullRequestReview) *base.Review {
631
631
}
632
632
}
633
633
634
- func convertGithubReviewComments (cs []* github.PullRequestComment ) []* base.ReviewComment {
634
+ func ( g * GithubDownloaderV3 ) convertGithubReviewComments (cs []* github.PullRequestComment ) ( []* base.ReviewComment , error ) {
635
635
var rcs = make ([]* base.ReviewComment , 0 , len (cs ))
636
636
for _ , c := range cs {
637
+ // get reactions
638
+ var reactions []* base.Reaction
639
+ for i := 1 ; ; i ++ {
640
+ g .sleep ()
641
+ res , resp , err := g .client .Reactions .ListIssueCommentReactions (g .ctx , g .repoOwner , g .repoName , c .GetID (), & github.ListOptions {
642
+ Page : i ,
643
+ PerPage : 100 ,
644
+ })
645
+ if err != nil {
646
+ return nil , err
647
+ }
648
+ g .rate = & resp .Rate
649
+ if len (res ) == 0 {
650
+ break
651
+ }
652
+ for _ , reaction := range res {
653
+ reactions = append (reactions , & base.Reaction {
654
+ UserID : reaction .User .GetID (),
655
+ UserName : reaction .User .GetLogin (),
656
+ Content : reaction .GetContent (),
657
+ })
658
+ }
659
+ }
660
+
637
661
rcs = append (rcs , & base.ReviewComment {
638
662
ID : c .GetID (),
639
663
InReplyTo : c .GetInReplyTo (),
@@ -643,12 +667,12 @@ func convertGithubReviewComments(cs []*github.PullRequestComment) []*base.Review
643
667
Position : c .GetPosition (),
644
668
CommitID : c .GetCommitID (),
645
669
PosterID : c .GetUser ().GetID (),
646
- Reactions : convertGithubReactions ( c . Reactions ) ,
670
+ Reactions : reactions ,
647
671
CreatedAt : c .GetCreatedAt (),
648
672
UpdatedAt : c .GetUpdatedAt (),
649
673
})
650
674
}
651
- return rcs
675
+ return rcs , nil
652
676
}
653
677
654
678
// GetReviews returns pull requests review
@@ -678,7 +702,12 @@ func (g *GithubDownloaderV3) GetReviews(pullRequestNumber int64) ([]*base.Review
678
702
return nil , fmt .Errorf ("error while listing repos: %v" , err )
679
703
}
680
704
g .rate = & resp .Rate
681
- r .Comments = append (r .Comments , convertGithubReviewComments (reviewComments )... )
705
+
706
+ cs , err := g .convertGithubReviewComments (reviewComments )
707
+ if err != nil {
708
+ return nil , err
709
+ }
710
+ r .Comments = append (r .Comments , cs ... )
682
711
if resp .NextPage == 0 {
683
712
break
684
713
}
0 commit comments