问题
I'm trying to figure out how to fetch the diff from a specific commit on Github. (Basically, just a series of individual file diffs, associated with a particular commit).
Some of the links on this question helped me figure out how to pull the contents of a given file in a repo, but I can't figure out how to pull the file for a particular commit.
OR, more to the point, how to pull the whole diff (pretty much as displayed when looking at a particular commit on Github).
Is there an easy way I'm missing to do this with the API? Or a Github gem for Rails that can do something like this? Took a look at the Git gem, but it doesn't seem to be what I'm looking for.
回答1:
You just need to set the Accept header in the request to application/vnd.github.diff.
curl -H "Accept: application/vnd.github.diff" https://api.github.com/repos/pengwynn/dotfiles/commits/aee60a4cd56fb4c6a50e60f17096fc40c0d4d72c
Source: http://developer.github.com/changes/2012-12-10-Diff-and-patch-media-types/
来源:https://stackoverflow.com/questions/18138885/github-api-v3-fetch-diff-of-specific-commit