Support for related pull requests view for Bitbucket Server

Issue #46 resolved
Kutsal Berberoglu created an issue

Bitbucket Server API has support for retrieving pull-requests for a repo:

https://<server-host>/rest/api/1.0/projects/<slug>/repos/<slug>/pull-requests

and commits per pull-request:

https://<server-host>/rest/api/1.0/projects/<slug>/repos/<slug>/pull-requests/<pr>/commits

Are there any plans to add support for this, currently cloud-only, feature?

Comments (7)

  1. Daniil Penkin staff

    Hello @kutsal,

    First of all, thanks for reaching out with the improvement proposal.

    I assume that you mean the "find pull requests where a specific commit has been reviewed in" feature of Bitbucket Linky plugin. Please correct me if I'm wrong. I somehow missed the word "related" in the issue title, sorry.

    It indeed works only with Cloud at the moment. The problem here is that it would be a huge change to support similar functionality for Server with the API endpoints you referred to. Specifically, Linky would need to index all PRs to build an inverted index commit → PRs, and then keep it up to date which requires some polling since listening to webhooks is not feasible.

    In Cloud this hard work is done by a third party plugin which you're required to install to use this Linky's feature in the IDE. That plugin essentially listens to the webhooks, builds and keeps in sync an inverted index I described above. Linky just uses its API to find the pull requests.

    In Bitbucket Server world, however, the ticket to support that right in the product is open, and there's no plugin providing similar functionality just yet. Also installing a plugin is not that easy with Server since you require admin rights for the entire instance whereas in Cloud you install the plugin just for your account.

    To summarize, I would love to make Linky also able to find PRs for commits in Bitbucket Server, but at the moment it is not really feasible.

    What I was thinking about as a workaround though is to go with a cheap option for now: walk through the commit tree locally, find related merge commits and check their commit messages. The default PR merge commit message contains the PR ID, so it would be possible to build a link to it. This approach has obviously at least two major flaws:

    • if the commit message is changed from the default one and doesn't match some expected pattern, the link could not be built (on merge user gets a dialog where they can change the commit message);
    • only merged PRs could be found since open and declined PRs don't have merge commits.

    Fetching all PRs and then all commits on every action invocation is definitely also an option but it would really suck on large repositories, so I'd not do that.

    If you have any ideas how to achieve the goal in a better way, please share.

    Cheers, Daniil

  2. Daniil Penkin staff

    Hey @kutsal,

    Good news: the ticket I referred to was resolved few months back, so I'm going to add this functionality into Linky now. It will only work with Bitbucket Server 5.11 or newer though.

    Cheers, Daniil

  3. Kutsal Berberoglu reporter

    This is great news. We're on 5.16 so that restriction would not be an issue for us.

  4. Log in to comment