diff --git a/bots-common/gitea_utils.go b/bots-common/gitea_utils.go index f61c74f..3eb958d 100644 --- a/bots-common/gitea_utils.go +++ b/bots-common/gitea_utils.go @@ -297,17 +297,15 @@ func (gitea *GiteaTransport) RequestReviews(pr *models.PullRequest, reviewer str func (gitea *GiteaTransport) IsReviewed(pr *models.PullRequest) (bool, error) { // TODO: get review from project git reviewers := pr.RequestedReviewers - var page, limit int64 - var reviews []*models.PullReview - page = 0 - limit = 20 + var page int64 + reviews := make([]*models.PullReview, 0, 10) for { + page++ res, err := gitea.client.Repository.RepoListPullReviews( repository.NewRepoListPullReviewsParams(). WithOwner(pr.Base.Repo.Owner.UserName). WithRepo(pr.Base.Repo.Name). - WithPage(&page). - WithLimit(&limit), + WithPage(&page), gitea.transport.DefaultAuthentication) if err != nil { @@ -315,15 +313,8 @@ func (gitea *GiteaTransport) IsReviewed(pr *models.PullRequest) (bool, error) { } if res.IsSuccess() { - r := res.Payload - - if reviews == nil { - reviews = r - } else { - reviews = append(reviews, r...) - } - - if len(r) < int(limit) { + reviews = append(reviews, res.Payload...) + if len(res.Payload) < 10 { break } }