git - 从 Github 下载私有(private)补丁

标签 git curl github

当在我组织的私有(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/

相关文章:

xcode - Mac终端返回 "xcrun: error: unable to exec Xcode native xcrun (Exec format error)."

git - 我的 git 分支在哪里?

github - 从 Github API 获取具体的 README.md 数据

Github 页面未显示我的 index.html 文件

git - git rm 是否删除文件的所有历史记录?

xcode - 对于 Xcode 项目,是否也可以将 .xcodeproj 文件添加到源代码管理中?

PHP curl 放 500 错误

PHP - 从 SOAP 响应中解析数据

php - 使用 CURL,给出 500 内部服务器错误

git - 如何设置 GoReleaser 将 brew tap 推送到不同的存储库