首页 > 解决方案 > Bitbucket rest api 获取任何两个分支之间存在的提交差异

问题描述

我正在尝试获取两个分支之间存在的提交差异列表以用于报告目的。假设我需要找出发布分支中存在的提交,而不是 prod 分支中的提交。所以为此我需要一个来自bitbucket的rest api,它将获取提交的差异。有什么帮助吗??https://bitbucket-xxx/rest/api/1.0/projects/MyProject/repos/repos1/compare/diff?from=release&to=prod

但它没有给出正确的输出。我想我没有使用适当的休息 api。

标签: bitbucketbitbucket-serverrestbitbucket-api

解决方案


我不确定 Bitbucket Server 版本,但对于 Cloud 版本,有一个 API 可以为您提供不同的提交。

curl --url "https://api.bitbucket.org/2.0/repositories/workspace/repository_name/commits/source_branch?exclude=destination_branch" --user username:password --request GET --header "Accept: application/json"

因此,您可以将源作为发布分支,将目标作为生产分支。此调用将为您提供源中存在但目标中不存在的一组提交。如果响应为空,则源中的所有提交都存在于目标中


推荐阅读