Skip to content

Commit 5b32a4d

Browse files
authored
Merge pull request #21530 from medyagh/fix_changelogscript
ci: changelog script paginate through more than 250 commits
2 parents 0c7dcb8 + 4939735 commit 5b32a4d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

hack/changelog/changelog.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,22 @@ func resolveStartRef(ctx context.Context, gh *github.Client, owner, repo, start
138138
// pullRequestsBetween finds all pull requests merged between start and end by
139139
// walking the commit comparison and querying PRs for each commit.
140140
func pullRequestsBetween(ctx context.Context, gh *github.Client, owner, repo, start, end string) map[int]*github.PullRequest {
141-
cmp, _, err := gh.Repositories.CompareCommits(ctx, owner, repo, start, end, nil)
142-
if err != nil {
143-
log.Fatalf("compare commits: %v", err)
141+
var allCommits []*github.RepositoryCommit
142+
opts := &github.ListOptions{PerPage: 100}
143+
for {
144+
cmp, resp, err := gh.Repositories.CompareCommits(ctx, owner, repo, start, end, opts)
145+
if err != nil {
146+
log.Fatalf("compare commits: %v", err)
147+
}
148+
allCommits = append(allCommits, cmp.Commits...)
149+
if resp.NextPage == 0 {
150+
break
151+
}
152+
opts.Page = resp.NextPage
144153
}
154+
145155
prsMap := make(map[int]*github.PullRequest)
146-
for _, c := range cmp.Commits {
156+
for _, c := range allCommits {
147157
prs, _, err := gh.PullRequests.ListPullRequestsWithCommit(ctx, owner, repo, c.GetSHA(), nil)
148158
if err != nil {
149159
log.Printf("list PRs for commit %s: %v", c.GetSHA(), err)

0 commit comments

Comments
 (0)