Skip to content

Commit 143c5b0

Browse files
m1ron0xFFEgor Balakin
and
Egor Balakin
authored
fix(githubPublishRelease): ListByRepo - enable pagination (#4509)
* fix githubPublishRelease --------- Co-authored-by: Egor Balakin <[email protected]>
1 parent d6d3b6b commit 143c5b0

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

cmd/githubPublishRelease.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,19 @@ func getClosedIssuesText(ctx context.Context, publishedAt github.Timestamp, conf
115115
if len(config.Labels) > 0 {
116116
options.Labels = config.Labels
117117
}
118-
ghIssues, _, err := ghIssueClient.ListByRepo(ctx, config.Owner, config.Repository, &options)
119-
if err != nil {
120-
log.Entry().WithError(err).Error("Failed to get GitHub issues.")
118+
119+
var ghIssues []*github.Issue
120+
for {
121+
issues, resp, err := ghIssueClient.ListByRepo(ctx, config.Owner, config.Repository, &options)
122+
if err != nil {
123+
log.Entry().WithError(err).Error("failed to get GitHub issues")
124+
}
125+
126+
ghIssues = append(ghIssues, issues...)
127+
if resp.NextPage == 0 {
128+
break
129+
}
130+
options.Page = resp.NextPage
121131
}
122132

123133
prTexts := []string{"**List of closed pull-requests since last release**"}

cmd/githubPublishRelease_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func (g *ghRCMock) UploadReleaseAsset(ctx context.Context, owner string, repo st
8484

8585
type ghICMock struct {
8686
issues []*github.Issue
87+
response github.Response
8788
lastPublished time.Time
8889
owner string
8990
repo string
@@ -95,7 +96,7 @@ func (g *ghICMock) ListByRepo(ctx context.Context, owner string, repo string, op
9596
g.repo = repo
9697
g.options = opt
9798
g.lastPublished = opt.Since
98-
return g.issues, nil, nil
99+
return g.issues, &g.response, nil
99100
}
100101

101102
func TestRunGithubPublishRelease(t *testing.T) {

0 commit comments

Comments
 (0)