Skip to content

Commit f49c77e

Browse files
committed
ci: changelog script paginate through more than 250 commits
1 parent 0c7dcb8 commit f49c77e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

hack/changelog/changelog.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -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)