5

According to GitHub Api V3 Document, to get a single commit you use this

https://api.github.com/repos:owner/repo:commits/sha

I can access the api but didn't give me the right result

I should get 373 files, but I only got 300?

what's wrong, does github also have limitations when retrieving details of a single commit?

note:

I already checked my page and take a look with the commit im referring to, It shows that 373 files were changed.

Thank You for any Help!

1 Answers1

2

The GitHub API docs don’t seem to mention a specific limit on commit listings but a 300-file limit is mentioned in other places in the docs; for example, the docs for the API for listing pull-request files:

Note: The response includes a maximum of 300 files.

And in the Limits for viewing content and diffs in a repository docs:

Most of the limits below affect both GitHub Enterprise and the API.


Diff limits

Because diffs can become very large, we impose these limits on diffs for commits, pull requests, and compare views:

  • No single file's diff may exceed 3,000 lines or 100 KB of raw diff data. The total size of a diff across all files in a view may not exceed 20,000 lines or 1 MB.

  • The maximum number of files in a single diff is limited to 300.

The 300-file limit is also mentioned here at Stackoverflow in other answers:

Those both quote a GitHub rep as saying:

We have some limits on diffs that we show in the browser in order to keep the pull request and compare pages working. Currently, we cut them off at:

  • 300 files,
  • a total diff of 1MB,
  • and an individual diff of 100KB.

If your diffs exceed the limits and can't be viewed online, you can always pull the changes locally and view the diff there. It may not be as convenient for you, but it'll get the job done.

Community
  • 1
  • 1
sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
  • Hi @sidesshowbarker, thank you for your reply. But I'm not after the diffs of a file, what I need is to get the filename or filepath, additions, deletions and changes. do you think the 300 limit rule also applies when getting a single commit? They dont even put a note in the commit section that they limit response to 300 files only or response size. Is there any way like pagination where I can iterate pages to get all commits like getting a list of commits to get all changed files of a singe commit? – Francis Carillo Mar 02 '17 at 03:04
  • Yeah it seems the 300-limit rule also applies when getting a single commit. As far as iterating to get more, you could try appending `?page=2` to the request URL and see what you get https://developer.github.com/guides/traversing-with-pagination/ – sideshowbarker Mar 02 '17 at 03:13
  • sorry I was not able to mention earlier that I already tried that but no luck. expecting to get the extended outputs of a single commit request, I got the list of commits instead. I mean could there be a pagination for a single commit but only have a different structure of url or request? Thanks for your much appreciated answers. – Francis Carillo Mar 02 '17 at 03:17
  • sorry my mistake, it did not give the list of commits, it just give the same result of the first request. – Francis Carillo Mar 02 '17 at 03:25
  • Yeah so unfortunately then it sounds like the 300 limit in this case is a hard limit, with no clear way through the API to get more than that. Certainly the docs don’t make any mention of how you could. – sideshowbarker Mar 02 '17 at 04:04
  • @FrancisCarillo I am having the same issue. Did you find any solution/workaround to get more than 300 results? – VK_nandi Dec 19 '17 at 01:25
  • @user3027732 Actually i forget if what I'm about to tell you is referring to this issue. Try to look at the response headers, i think you will see links there which can be used for paging or pagination. – Francis Carillo Dec 20 '17 at 07:46
  • @FrancisCarillo I used the "Link" header to retrieve the next page urls until last. Even then I was only able to receive 300 files while my PR has over 700 files. I reached out to Github support and they mentioned that they are limited to 300 for now and only option is to pull the repo locally and do a diff. So I want to know if you found another solution/workaround? – VK_nandi Dec 21 '17 at 20:54
  • @user3027732 I checked the program I created before which is related to this and no luck. I can only fetch 300 files. I also already talked to git about this and they just told me that for now, they will only give 300 files as response for single commit details request. Maybe you can wait for their updates and improvements. – Francis Carillo Dec 22 '17 at 03:02
  • @user307732 Then i think the we don't have other options. There will be no other way since it was github itself whose limiting its result. All we can do now is to wait for github to do enhancements with their services hoping that includes the size of the results of their api methods. – Francis Carillo Feb 24 '18 at 01:50