当在我组织的私有(private)仓库中创建 PR 时,我会收到来自 Github 的电子邮件,其中包含类似 http://github.com/<my org>/<project>/<PR #>.patch
的链接。 .我想用 curl 下载这样的链接;照原样,我得到了 404,而且我似乎无法用 -H "Authorization: <oauth token>"
找到正确的咒语使其发挥作用。
最佳答案
您可以使用 Github API 来执行此操作,使用 this API 获取 pull 请求:
GET /repos/:owner/:repo/pulls/:number
您可以使用 personal access token使用 repos
范围获取带有授权 header 的私有(private) repo 的结果:-H 'Authorization: token YOUR_TOKEN'
使用commits comparison and pull request媒体类型:
- 补丁:
application/vnd.github.VERSION.patch
- 差异:
application/vnd.github.VERSION.diff
curl 请求是:
请求 PR #18 的补丁:
curl -H 'Authorization: token YOUR_TOKEN' \ -H 'Accept: application/vnd.github.VERSION.patch' \ https://api.github.com/repos/<my org>/<project>/pulls/18
请求 PR #18 的差异
curl -H 'Authorization: token YOUR_TOKEN' \ -H 'Accept: application/vnd.github.VERSION.diff' \ https://api.github.com/repos/<my org>/<project>/pulls/18
关于git - 从 Github 下载私有(private)补丁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44547857/