Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

List of merged branches of a repo

Hello folks,

 

Bitbucket Server 7.17.1

When I click on 'Branches' menu for any repository, I get a list like this:

image.png

The objective is to get only those branches(and NOT pull requests) which are 'MERGED'.

I tried a call like this which returns ALL the branches:


https://git.net/rest/api/latest/projects/PRODSR/repos/prod-sr-onboarding/branches?base=refs%2Fheads%2Fintegration&details=true&start=0&limit=3&orderBy=MODIFICATION

Now, this returns a huge JSON response. For some PRs that are merged, the outgoing-pull-request-metadata gives some hint that the branch is merged:


"com.atlassian.bitbucket.server.bitbucket-ref-metadata:outgoing-pull-request-metadata": {
"pullRequest": {
"id": 337,
"version": 2,
"title": "feat(CFEM2-3668): updated realmId and accountTypeId",
"state": "MERGED",
"open": false,
"closed": true,
"createdDate": 1638452656131,
"updatedDate": 1638453446194,
"closedDate": 1638453446194,
"fromRef": {
"id": "refs/heads/p901zid-realmidentifier-test",
"displayId": "p901zid-realmidentifier-test",
"latestCommit": "4963b5887109fdd1f830f980b91575c9beb00a2b",
"type": "BRANCH",
"repository": {
"slug": "core-aggregation",
"id": 43534,
"name": "core-aggregation",
"description": "#1033 -",
"hierarchyId": "665f542ffae31d82fba5",
"scmId": "git",
"state": "AVAILABLE",
"statusMessage": "Available",
"forkable": true,
"project": {
"key": "AISA",
"id": 3710,
"name": "Account Aggregation",
"description": "#1033 - A service to aggregate external institutes.",
"public": false,
"type": "NORMAL"
},
"public": false
}
},
"toRef": {
"id": "refs/heads/integration",
"displayId": "integration",
"latestCommit": "fd846ade2bb587ab0b4f1dd025667baf14ce78e2",
"type": "BRANCH",
"repository": {
"slug": "core-aggregation",
"id": 43534,
"name": "core-aggregation",
"description": "#1033 -",
"hierarchyId": "665f542ffae31d82fba5",
"scmId": "git",
"state": "AVAILABLE",
"statusMessage": "Available",
"forkable": true,
"project": {
"key": "AISA",
"id": 3710,
"name": "Account Aggregation",
"description": "#1033 - A service to aggregate external institutes",
"public": false,
"type": "NORMAL"
},
"public": false
}
},
"locked": false,
"author": {
...
},
"reviewers": [....
],
"participants": []
}
}

but for some branches(probably, with OPEN PRs or similar), the outgoing-pull-request-metadata object is quite small:

"com.atlassian.bitbucket.server.bitbucket-ref-metadata:outgoing-pull-request-metadata": {
"open": 1,
"merged": 7,
"declined": 0
}

So, what is the most efficient/optimal way to query and retrieve only those branches which are shown as 'MERGED'?

 

Regards,

Kali

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

183 views 2 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you