我在Bitbucket上有一个只有我有写入权限的存储库。
有人分叉了该存储库,进行了更改,并从分支向我的存储库发出了拉取请求。
如何将该拉取请求作为 git 补丁临时应用于我的存储库以进行测试?
分叉存储库是私有的,所以我无法将其拉下来,无论如何我都不想这样做。
在 GitHub 上,您只需转到拉取请求并在 url 末尾添加一个 .patch 即可下载补丁。这不适用于Bitbucket。
拉取请求补丁可通过 bitbucket API 获得(尽管没有直接从拉取请求页面下载它的按钮)。
访问拉取请求补丁:https://bitbucket.org/api/2.0/repositories/GROUP/PROJECT/pullrequests/ID/diff
源:https://jira.atlassian.com/browse/BCLOUD-8323?focusedCommentId=2226612&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2226612
对于 7.x 版本,您可以根据 https://docs.atlassian.com/bitbucket-server/rest/7.11.1/bitbucket-rest.wadl 和 https://docs.atlassian.com/bitbucket-server/rest/7.11.1/bitbucket-git-rest.html 的信息尝试以下链接:
拉取请求:https://bitbucket.example.com/rest/api/1.0/projects/GROUP/repos/PROJECT/pull-requests/ID.patch
提交:https://bitbucket.example.com/rest/api/1.0/projects/GROUP/repos/PROJECT/patch?until=COMMIT
(也可以尝试使用 since=
查询参数进行起始提交)。
补充上面尼克·斯皮尔的答案:
您需要在请求中包含访问令牌,否则将收到权限错误。