Github API v3-获取特定提交的差异

Sas*_*sha 2 ruby-on-rails github github-api ruby-on-rails-3

我试图弄清楚如何从Github上的特定提交中获取差异。(基本上,只有一系列与特定提交相关的单个文件差异)。

这个问题上的某些链接帮助我弄清楚了如何在存储库中提取给定文件的内容,但是我无法弄清楚如何为特定的提交提取文件。

或者,更重要的是,如何拉动整个差异(与在Github上查看特定提交时所显示的差不多)。

有没有一种我不希望使用API​​的简便方法?还是Github的Rails宝石可以做到这样?看了一下Git的宝石,但这似乎并不是我想要的。

Ben*_*ton 5

您只需要将请求中的Accept标头设置为application / vnd.github.diff即可

curl -H "Accept: application/vnd.github.diff" https://api.github.com/repos/pengwynn/dotfiles/commits/aee60a4cd56fb4c6a50e60f17096fc40c0d4d72c
Run Code Online (Sandbox Code Playgroud)

来源:http : //developer.github.com/changes/2012-12-10-Diff-and-patch-media-types/