Skip to content

Commit

Permalink
Fix bug of migrate comments which only fetch one page (go-gitea#17055)
Browse files Browse the repository at this point in the history
* Fix bug of migrate comments which only fetch one page

* add next page to trace

Co-authored-by: zeripath <art27@cantab.net>
  • Loading branch information
lunny and zeripath committed Sep 15, 2021
1 parent 6a025d8 commit 43e1040
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/migrations/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment,
created = "created"
asc = "asc"
)
if perPage > g.maxPerPage {
perPage = g.maxPerPage
}
opt := &github.IssueListCommentsOptions{
Sort: &created,
Direction: &asc,
Expand All @@ -555,7 +558,9 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment,
if err != nil {
return nil, false, fmt.Errorf("error while listing repos: %v", err)
}
log.Trace("Request get comments %d/%d, but in fact get %d", perPage, page, len(comments))
var isEnd = resp.NextPage == 0

log.Trace("Request get comments %d/%d, but in fact get %d, next page is %d", perPage, page, len(comments), resp.NextPage)
g.rate = &resp.Rate
for _, comment := range comments {
var email string
Expand Down Expand Up @@ -600,7 +605,7 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment,
})
}

return allComments, len(allComments) < perPage, nil
return allComments, isEnd, nil
}

// GetPullRequests returns pull requests according page and perPage
Expand Down

0 comments on commit 43e1040

Please sign in to comment.