Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,359,776
Community Members
 
Community Events
168
Community Groups

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

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

3,448 views 3 10
Read article

Atlassian Community Events