Skip to content

Commit 45ebcb0

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

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/migrations/github.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,9 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment,
521521
created = "created"
522522
asc = "asc"
523523
)
524+
if perPage > g.maxPerPage {
525+
perPage = g.maxPerPage
526+
}
524527
opt := &github.IssueListCommentsOptions{
525528
Sort: &created,
526529
Direction: &asc,
@@ -535,7 +538,9 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment,
535538
if err != nil {
536539
return nil, false, fmt.Errorf("error while listing repos: %v", err)
537540
}
538-
log.Trace("Request get comments %d/%d, but in fact get %d", perPage, page, len(comments))
541+
var isEnd = resp.NextPage == 0
542+
543+
log.Trace("Request get comments %d/%d, but in fact get %d, next page is %d", perPage, page, len(comments), resp.NextPage)
539544
g.rate = &resp.Rate
540545
for _, comment := range comments {
541546
// get reactions
@@ -575,7 +580,7 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment,
575580
})
576581
}
577582

578-
return allComments, len(allComments) < perPage, nil
583+
return allComments, isEnd, nil
579584
}
580585

581586
// GetPullRequests returns pull requests according page and perPage

0 commit comments

Comments
 (0)