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

Return all files from a commit #1679

Merged
merged 12 commits into from
Jun 30, 2023
Merged

Return all files from a commit #1679

merged 12 commits into from
Jun 30, 2023

Conversation

frink182
Copy link
Contributor

Description

Fixes #1669
If there are more than 300 files in the commit diff, the GitHub API 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. This PR adds GHCommit.listFiles() which returns the list of files in a commit via paginated responses. It deprecates the previous method to get the files: GHCommit.getFiles().

The PR also populates the message in a GHCommit which was previously null.

Before submitting a PR:

  • Changes must not break binary backwards compatibility. If you are unclear on how to make the change you think is needed while maintaining backward compatibility, CONTRIBUTING.md for details.
  • Add JavaDocs and other comments explaining the behavior.
  • When adding or updating methods that fetch entities, add @link JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .
  • Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See CONTRIBUTING.md for details.
  • Run mvn -D enable-ci clean install site locally. If this command doesn't succeed, your change will not pass CI.
  • Push your changes to a branch other than main. You will create your PR from that branch.

When creating a PR:

  • Fill in the "Description" above with clear summary of the changes. This includes:
    • If this PR fixes one or more issues, include "Fixes #" lines for each issue.
    • Provide links to relevant documentation on https://docs.github.com/en/rest where possible. If not including links, explain why not.
  • All lines of new code should be covered by tests as reported by code coverage. Any lines that are not covered must have PR comments explaining why they cannot be covered. For example, "Reaching this particular exception is hard and is not a particular common scenario."
  • Enable "Allow edits from maintainers".

@frink182 frink182 changed the title Return all files from a commit - #1669 Return all files from a commit Jun 23, 2023
@codecov
Copy link

codecov bot commented Jun 29, 2023

Codecov Report

Patch coverage: 82.14% and project coverage change: +0.02 🎉

Comparison is base (c494891) 80.02% compared to head (dd8f907) 80.04%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1679      +/-   ##
============================================
+ Coverage     80.02%   80.04%   +0.02%     
- Complexity     2224     2231       +7     
============================================
  Files           213      215       +2     
  Lines          6733     6760      +27     
  Branches        365      365              
============================================
+ Hits           5388     5411      +23     
- Misses         1131     1134       +3     
- Partials        214      215       +1     
Impacted Files Coverage Δ
src/main/java/org/kohsuke/github/GHCompare.java 92.30% <ø> (ø)
...ain/java/org/kohsuke/github/GHCommitFilesPage.java 50.00% <50.00%> (ø)
.../java/org/kohsuke/github/GHCommitFileIterable.java 89.47% <89.47%> (ø)
src/main/java/org/kohsuke/github/GHCommit.java 88.18% <100.00%> (+1.14%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@bitwiseman bitwiseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically all one big change suggestion to make listFiles() return a PagedIterable.
Other than that, this PR looks great! Well tested.

src/main/java/org/kohsuke/github/GHCommit.java Outdated Show resolved Hide resolved
src/main/java/org/kohsuke/github/GHCommitIterable.java Outdated Show resolved Hide resolved
src/main/java/org/kohsuke/github/GHCommit.java Outdated Show resolved Hide resolved
src/main/java/org/kohsuke/github/GHCommit.java Outdated Show resolved Hide resolved
src/main/java/org/kohsuke/github/GHCommit.java Outdated Show resolved Hide resolved
src/main/java/org/kohsuke/github/GHCommitIterable.java Outdated Show resolved Hide resolved
src/main/java/org/kohsuke/github/GHCommitIterable.java Outdated Show resolved Hide resolved
@frink182
Copy link
Contributor Author

@bitwiseman I've made the suggested changes, let me know how it looks now. Thanks

@bitwiseman bitwiseman self-requested a review June 30, 2023 18:24
@bitwiseman bitwiseman merged commit e45932d into hub4j:main Jun 30, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GHCommit.getFiles() limited to 300 files, does not support pagination
2 participants