bitbucket API Rest - 从存储库获取分支

bitbucket API Rest - Getting branches from a repository

我正在寻找可用于 bitbucket API 的关于从存储库和特定分支获取分支的端点列表。

我期待看到类似这样的内容:

GET /2.0/repositories/{workspace}/{repo_slug}/branches/

GET /2.0/repositories/{workspace}/{repo_slug}/branches/{branch}

所以我可以从特定分支获取提交。

我知道 I can get commits 但是对于这个端点,它的范围在存储库的角度。

你知道是否有端点可以处理分支并递归到它的层次结构中吗? 我查看了 documentation for API 2.0,但没有看到我要找的东西,所以这就是我在这里发布这个问题的原因。

另外,我前段时间看到按this answer是不行的,但属于API的1.0版本。现在还是这样吗?

点击this endpoint时:

https://api.bitbucket.org/2.0/repositories/<workspace>/<repository-name>`
# GET /2.0/repositories/{workspace}/{repo_slug}

结果是 JSON 文档。在 links 属性中,您有一个名为 branches 的键。它是这样的:

{
    "scm": "git",
    "has_wiki": false,
    "links": {
        "watchers": {
            "href": "https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/watchers"
        },
        "branches": {
            "href": "https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/refs/branches"
        },
     ....

因此您可以到达终点并获得分支:

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/refs/branches
# GET /2.0/repositories/{workspace}/{repo_slug}/refs/branches

并通过

获得一个特定的分支
https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/refs/branches/<branch-name>
# GET /2.0/repositories/{workspace}/{repo_slug}/refs/branches/<branch-name>