Skip to content

Commit fd35f56

Browse files
lunnyzeripath
andauthored
Fix bug of migrate comments which only fetch one page (go-gitea#17055) (go-gitea#17058)
* Fix bug of migrate comments which only fetch one page * add next page to trace Co-authored-by: zeripath <[email protected]> Co-authored-by: zeripath <[email protected]>
1 parent 1f8df5d commit fd35f56

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/migrations/github.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment,
541541
created = "created"
542542
asc = "asc"
543543
)
544+
if perPage > g.maxPerPage {
545+
perPage = g.maxPerPage
546+
}
544547
opt := &github.IssueListCommentsOptions{
545548
Sort: &created,
546549
Direction: &asc,
@@ -555,7 +558,9 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment,
555558
if err != nil {
556559
return nil, false, fmt.Errorf("error while listing repos: %v", err)
557560
}
558-
log.Trace("Request get comments %d/%d, but in fact get %d", perPage, page, len(comments))
561+
var isEnd = resp.NextPage == 0
562+
563+
log.Trace("Request get comments %d/%d, but in fact get %d, next page is %d", perPage, page, len(comments), resp.NextPage)
559564
g.rate = &resp.Rate
560565
for _, comment := range comments {
561566
var email string
@@ -600,7 +605,7 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment,
600605
})
601606
}
602607

603-
return allComments, len(allComments) < perPage, nil
608+
return allComments, isEnd, nil
604609
}
605610

606611
// GetPullRequests returns pull requests according page and perPage

0 commit comments

Comments
 (0)