Skip to content

Commit

Permalink
fix: github pagination starts at page 1, not 0
Browse files Browse the repository at this point in the history
Unfortunately, starting to count at 1 hasn't yet been outlawed.

Signed-off-by: Duarte Nunes <[email protected]>
  • Loading branch information
duarten committed Aug 25, 2020
1 parent 9c85bcf commit 1d252c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ function getChangedFiles(client, prNumber, fileCount) {
const pattern = core.getInput("pattern");
const changedFiles = new ChangedFiles(new RegExp(pattern.length ? pattern : ".*"));
const fetchPerPage = 100;
for (let pageIndex = 0; pageIndex * fetchPerPage < fileCount; pageIndex++) {
for (let pageIndex = 1; (pageIndex - 1) * fetchPerPage < fileCount; pageIndex++) {
const listFilesResponse = yield client.pulls.listFiles({
owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo,
Expand Down Expand Up @@ -1569,7 +1569,7 @@ function getEncoder() {
case "string":
return files => files.join(" ");
default:
throw new Error('"result-encoding" must be either "string" or "json"');
throw new Error("'result-encoding' must be either 'string' or 'json'");
}
}
function run() {
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function getChangedFiles(client: GitHub, prNumber: number, fileCount: numb
const pattern = core.getInput("pattern")
const changedFiles = new ChangedFiles(new RegExp(pattern.length ? pattern : ".*"))
const fetchPerPage = 100
for (let pageIndex = 0; pageIndex * fetchPerPage < fileCount; pageIndex++) {
for (let pageIndex = 1; (pageIndex - 1) * fetchPerPage < fileCount; pageIndex++) {
const listFilesResponse = await client.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down Expand Up @@ -87,7 +87,7 @@ function getEncoder(): (files: string[]) => string {
case "string":
return files => files.join(" ")
default:
throw new Error('"result-encoding" must be either "string" or "json"')
throw new Error("'result-encoding' must be either 'string' or 'json'")
}
}

Expand Down

0 comments on commit 1d252c6

Please sign in to comment.