msmyamada
msmyamada

Reputation: 81

Github API - compare 2 commits - large comparison - can't get all changed Files

I'm using Compare two commits API to compare 2 commits.

/repos/{owner}/{repo}/compare/{basecommitID}...{headcommitID}?page=1&per_page=30

And since it's a large comparison, it contains more than 300 changed files.

According to Compare two commits API it says "To process a response with a large number of commits, you can use (per_page or page) to paginate the results. When using paging, the list of changed files is only returned with page 1, but includes all changed files for the entire comparison."

However, I don't see all changed files in the page 1. Page 1 contains only first 300 changed files. And from page 2, they don't contain any Files diff information.

So is there any way to get the all changed files (e.g. 1000 changed files), using this API?

Upvotes: 6

Views: 1001

Answers (1)

Deepak Patankar
Deepak Patankar

Reputation: 3272

The compare-commits API returns the files changed between two commits, but it only returns 300 files in one API call.

If you use the API to return the output in the diff format, then it returns all the files changed.

eg:

  curl \
  -H "Accept: application/vnd.github.v3.diff" \  https://api.github.com/repos/<repoOwner>/<repoName>/compare/commitId...commit2

Upvotes: 3

Related Questions