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

发布于 2025-01-16 19:00:24 字数 863 浏览 3 评论 0原文

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

我期望看到类似的内容:

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

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

这样我就可以从特定分支获取提交。

我知道 我可以获得提交,但使用此端点,其范围位于存储库视角下。

您是否知道是否有端点可以与分支一起工作并递归到其层次结构中? 我查看了 API 2.0 文档,但我没有看到我想要的内容一直在寻找,所以这就是我在这里发布这个问题的原因。

此外,我前段时间看到根据这个答案,但它属于API的1.0版本。这仍然是真的吗?

I am looking for the list of endpoints available for bitbucket API regarding get the branches from a repository and a specific branch.

I was expecting to see something like:

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

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

So I can get the commits from a specific branch. 

I know I can get commits but with this endpoint, its scope is under repository perspective. 

Do you know if there are endpoints to work with branches and recursively into its hierarchy?
I looked over the documentation for API 2.0 but I did not see what I was looking for so that is why I am posting this question here.

In addition, I see some time ago that was not possible according to this answer, but it belongs to the version 1.0 of the API. Is it still true? 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

混吃等死 2025-01-23 19:00:24

当点击 此端点

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>

When hitting this endpoint:

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

You get as a result a JSON document. In the links attribute you got a key called branches. It is something like this:

{
    "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"
        },
     ....

So you can hit the endpoint and get the branches:

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

And get a specific branch with

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文