Github API v3 - Fetch diff of specific commit

怎甘沉沦 提交于 2019-12-12 16:36:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!