Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retrieve all changes via api #50

Merged
merged 2 commits into from
Nov 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from 'fs'
import * as core from '@actions/core'
import * as github from '@actions/github'
import {Webhooks} from '@octokit/webhooks'
import type {Octokit} from '@octokit/rest'

import {Filter, FilterResults} from './filter'
import {File, ChangeStatus} from './file'
Expand Down Expand Up @@ -127,8 +128,10 @@ async function getChangedFilesFromApi(
const client = new github.GitHub(token)
const pageSize = 100
const files: File[] = []
for (let page = 0; page * pageSize < pullRequest.changed_files; page++) {
const response = await client.pulls.listFiles({
let response: Octokit.Response<Octokit.PullsListFilesResponse>
let page = 0
do {
response = await client.pulls.listFiles({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
pull_number: pullRequest.number,
Expand Down Expand Up @@ -156,7 +159,8 @@ async function getChangedFilesFromApi(
})
}
}
}
page++
} while (response?.data?.length > 0)

return files
}
Expand Down