Skip to content

Commit 1d252c6

Browse files
committed
fix: github pagination starts at page 1, not 0
Unfortunately, starting to count at 1 hasn't yet been outlawed. Signed-off-by: Duarte Nunes <duarte.m.nunes@gmail.com>
1 parent 9c85bcf commit 1d252c6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ function getChangedFiles(client, prNumber, fileCount) {
15261526
const pattern = core.getInput("pattern");
15271527
const changedFiles = new ChangedFiles(new RegExp(pattern.length ? pattern : ".*"));
15281528
const fetchPerPage = 100;
1529-
for (let pageIndex = 0; pageIndex * fetchPerPage < fileCount; pageIndex++) {
1529+
for (let pageIndex = 1; (pageIndex - 1) * fetchPerPage < fileCount; pageIndex++) {
15301530
const listFilesResponse = yield client.pulls.listFiles({
15311531
owner: github_1.context.repo.owner,
15321532
repo: github_1.context.repo.repo,
@@ -1569,7 +1569,7 @@ function getEncoder() {
15691569
case "string":
15701570
return files => files.join(" ");
15711571
default:
1572-
throw new Error('"result-encoding" must be either "string" or "json"');
1572+
throw new Error("'result-encoding' must be either 'string' or 'json'");
15731573
}
15741574
}
15751575
function run() {

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function getChangedFiles(client: GitHub, prNumber: number, fileCount: numb
4343
const pattern = core.getInput("pattern")
4444
const changedFiles = new ChangedFiles(new RegExp(pattern.length ? pattern : ".*"))
4545
const fetchPerPage = 100
46-
for (let pageIndex = 0; pageIndex * fetchPerPage < fileCount; pageIndex++) {
46+
for (let pageIndex = 1; (pageIndex - 1) * fetchPerPage < fileCount; pageIndex++) {
4747
const listFilesResponse = await client.pulls.listFiles({
4848
owner: context.repo.owner,
4949
repo: context.repo.repo,
@@ -87,7 +87,7 @@ function getEncoder(): (files: string[]) => string {
8787
case "string":
8888
return files => files.join(" ")
8989
default:
90-
throw new Error('"result-encoding" must be either "string" or "json"')
90+
throw new Error("'result-encoding' must be either 'string' or 'json'")
9191
}
9292
}
9393

0 commit comments

Comments
 (0)