BitBucket 使用 REST 比较分支 API

BitBucket Compare Branches using REST API

我正在开发一个 java 实用程序来从代码创建拉取请求,而不是使用网页。

在创建拉取请求之前,我想比较我想要创建拉取请求的分支,比较分支的差异,确定任何合并问题。

我正在寻找 REST 端点,它允许我在知道分支名称时比较分支,而不必确定它们的最后一次提交 ID 以及如何从输出中识别合并问题。

如果有 cURL 方法可以做到这一点,那也行。

谢谢

您可以使用 Diff API 如下:

GET https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/diff/{spec} 

示例:

https://api.bitbucket.org/2.0/repositories/osrf/sdformat/diff/default..4_to_5

来自官方文档:

Produces a raw, git-style diff for either a single commit (diffed against its first parent), or a revspec of 2 commits (e.g. 3a8b42..9ff173 where the first commit represents the source and the second commit the destination). In case of the latter (diffing a revspec), a 3-way diff, or merge diff, is computed. This shows the changes introduced by the left branch (3a8b42 in our example) as compared againt the right branch (9ff173). This is equivalent to merging the left branch into the right branch and then computing the diff of the merge commit against its first parent (the right branch). This follows the same behavior as pull requests that also show this style of 3-way, or merge diff.

它适用于比较提交、标签和分支