Tuesday, 15 May 2012

GitHub API - how to compare 2 commits -



GitHub API - how to compare 2 commits -

it's possible list of chaged files between 2 commits. comparison between 2 commits in web version using github api.

the official commit comparing api compare 2 commits:

get /repos/:owner/:repo/compare/:base...:head

both :base , :head can either branch names in :repo or branch names in other repositories in same network :repo. latter case, utilize format user:branch:

get /repos/:owner/:repo/compare/user1:branchname...user2:branchname

note can utilize tags well. instance:

https://api.github.com/repos/git/git/compare/v2.2.0-rc1...v2.2.0-rc2

note '...', not '..' between 2 tags. , need have oldest tag first, newer tag.

that gives status:

"status": "behind", "ahead_by": 1, "behind_by": 2, "total_commits": 1,

and each commit, info files:

"files": [ { "sha": "bbcd538c8e72b8c175046e27cc8f907076331401", "filename": "file1.txt", "status": "added", "additions": 103, "deletions": 21, "changes": 124, "blob_url": "https://github.com/octocat/hello-world/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt", "raw_url": "https://github.com/octocat/hello-world/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt", "contents_url": "https://api.github.com/repos/octocat/hello-world/contents/file1.txt?ref=6dcb09b5b57875f334f61aebed695e2e4193db5e", "patch": "@@ -132,7 +132,7 @@ module test @@ -1000,7 +1000,7 @@ module test" } ]

but:

the response include comparison of 250 commits. if working larger commit range, can utilize commit list api enumerate commits in range.

for comparisons extremely big diffs, may receive error response indicating diff took long generate. can typically resolve error using smaller commit range.

github

No comments:

Post a Comment