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

GHCommit.getFiles() limited to 300 files, does not support pagination #1669

Closed
bitwiseman opened this issue Jun 1, 2023 · 0 comments · Fixed by #1679
Closed

GHCommit.getFiles() limited to 300 files, does not support pagination #1669

bitwiseman opened this issue Jun 1, 2023 · 0 comments · Fixed by #1679

Comments

@bitwiseman
Copy link
Member

bitwiseman commented Jun 1, 2023

Describe the bug
https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#get-a-commit

Note: If there are more than 300 files in the commit diff, the response will include pagination link headers for the remaining files, up to a limit of 3000 files. Each page contains the static commit information, and the only changes are to the file listing.

Except hub4j doesn't support pagination at this time:

public List<File> getFiles() throws IOException {
populate();
return files != null ? Collections.unmodifiableList(files) : Collections.<File>emptyList();
}

To Reproduce
Steps to reproduce the behavior:

  1. Use GHCommit.getFiles() on a commit with more than 300 files changed.

Expected behavior
Suggest deprecating getFiles() and adding a listFile() that returns a PagedIterable. However, I think that PagedIterable will need to be backed by a custom class similar to GHWorkflowsIterable with the GHCommit as the container. It's going to take some trial-and-error to figure out how this works.

frink182 pushed a commit to frink182/github-api that referenced this issue Jun 19, 2023
bitwiseman added a commit that referenced this issue Jun 30, 2023
* Fix for #1669

* Doc updates

* Add test data

* Spotless

* Javadoc changes

* Test comment fixes

* PR review changes

* Add required default constructor

* Update GHCommitFileIterable.java

---------

Co-authored-by: Steve <steve@slug.home>
Co-authored-by: Liam Newman <bitwiseman@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant