Skip to content

Commit e93df69

Browse files
committed
Add pagination
1 parent d7dcf74 commit e93df69

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

scripts/utils.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ async function hasRecentBotComment(
176176
async function hasLabel(name, owner, repo, issueNumber, github, core) {
177177
let labels = [];
178178
try {
179-
const response = await github.rest.issues.listLabelsOnIssue({
179+
const allLabels = await github.paginate(github.rest.issues.listLabelsOnIssue, {
180180
owner,
181181
repo,
182182
issue_number: issueNumber,
183183
});
184-
labels = response.data.map(label => label.name);
184+
labels = allLabels.map(label => label.name);
185185
} catch (error) {
186186
core.warning(`Failed to fetch labels on issue #${issueNumber}: ${error.message}`);
187187
labels = [];
@@ -194,14 +194,14 @@ async function hasLabel(name, owner, repo, issueNumber, github, core) {
194194
*/
195195
async function getIssues(assignee, state, owner, repos, github, core) {
196196
const promises = repos.map(repo =>
197-
github.rest.issues
198-
.listForRepo({
197+
github
198+
.paginate(github.rest.issues.listForRepo, {
199199
owner,
200200
repo,
201201
assignee,
202202
state,
203203
})
204-
.then(response => response.data.filter(issue => !issue.pull_request))
204+
.then(issues => issues.filter(issue => !issue.pull_request))
205205
.catch(error => {
206206
core.warning(`Failed to fetch issues from ${repo}: ${error.message}`);
207207
return [];
@@ -217,13 +217,13 @@ async function getIssues(assignee, state, owner, repos, github, core) {
217217
*/
218218
async function getPullRequests(author, state, owner, repos, github, core) {
219219
const promises = repos.map(repo =>
220-
github.rest.pulls
221-
.list({
220+
github
221+
.paginate(github.rest.pulls.list, {
222222
owner,
223223
repo,
224224
state,
225225
})
226-
.then(response => response.data.filter(pr => pr.user.login === author))
226+
.then(prs => prs.filter(pr => pr.user.login === author))
227227
.catch(error => {
228228
core.warning(`Failed to fetch pull requests from ${repo}: ${error.message}`);
229229
return [];

0 commit comments

Comments
 (0)