Skip to content

Commit

Permalink
fix: retrieve all changes via api
Browse files Browse the repository at this point in the history
the number returned by pullRequest.changed_files doesn't reflect the correct number of real changed files. Therefore lot of filters didn't work in my scenario, as it said nothing has changed. This especially happens if there are more than 100 files changed (first time I experienced it where over 1000 files have changed, and now when there were about 300 files that have changed). 

I changed the detection by querying the api as long as it returns new results. This ensures all pages have been retrieved. It's tested and used in production on our end, but please check again if I didn't miss anything.

Thanks a lot for this awesome github action :)
  • Loading branch information
Simon Tretter authored and GitHub committed Nov 13, 2020
1 parent b4eabb6 commit e84bc6a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,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 +158,8 @@ async function getChangedFilesFromApi(
})
}
}
}
page++
} while (response?.data?.length > 0)

return files
}
Expand Down

0 comments on commit e84bc6a

Please sign in to comment.