PyGithub icon indicating copy to clipboard operation
PyGithub copied to clipboard

commit.files result has a limit of 300 files, can I get infomation of all files?

Open jessieyanl opened this issue 5 years ago • 3 comments

commit.files result has a limit of 300 files. I have a large commit that has 926 changed files and I need to list the changes. when I use
files = commit.files print(len(commit.files)) I got 300. Can I get all the files?

jessieyanl avatar Nov 05 '20 08:11 jessieyanl

We are at the mercy of whatever data GitHub returns here. Files is populated directly from the JSON returned. If you need to do something like that, I would suggest a local clone and using a library to work with the git data directly, such as https://www.pygit2.org/

s-t-e-v-e-n-k avatar Nov 10 '20 07:11 s-t-e-v-e-n-k

@s-t-e-v-e-n-k @jessieyanl sorry for reopening an old issue, but - /commits/{ref} endpoint is (at least now) paginated, meaning you can get up to 3000 files per commit:

Note: If there are more than 300 files in the commit diff and the default JSON media type is requested, 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.

iarspider avatar Mar 12 '24 13:03 iarspider

That might be the same kind of pagination that had recently been supported for Repository.compare().commits: #2882

Happy to review fixes for Commit.files.

EnricoMi avatar Mar 12 '24 14:03 EnricoMi