Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

List of merged branches of a repo

Kaliyug Antagonist December 3, 2021

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
AUG Leaders

Atlassian Community Events