All branches ahead master API

Jeroen Roosendaal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 3, 2025

Hi All,

Is there a way to get all the branches that are ahead of master using the api?

I can call the API to get all the branches, and then compare these with the master branch. But this is very slow for all the branches that we have. 

In de web view from bitbucket they use the internal API call 

 

https://bitbucket.org/!api/internal/repositories/axiretail/bijenkorf/branch-list/?q=name

but this one isn't available in the API 2.0. 

Any suggestions? 

 

 

 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 4, 2025

Hi Jeroen and welcome to the community!

As you already figured out, this info is not available via the API. We have a feature request about this here:

You can add your vote to that feature request (by selecting the link Vote for this issue) to express your interest. You are more than welcome to leave feedback, and you can also add yourself as a watcher (by selecting the link Start watching this issue) if you'd like to be notified via email on updates.

Implementation of features is done as per our policy here and any updates will be posted in the feature request.

In the meantime, if you want to perform this operation via API, you'll need to do it for each branch.

The following API endpoint returns commits that are reachable by a certain branch but not by another:

So, a call to this:

https://api.bitbucket.org/2.0/repositories/workspace-id/repo/commits/dev?exclude=master

will return all commits of the branch named dev that are not reachable by master branch.

If the output is not empty and it returns commits, it means that the dev branch is ahead of master by some commits.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events