• Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      In the Bitbucket web interface, one can filter the branch list as Active or Merged. I would like to use the REST API to get the list of Merged branches but it seems this is not supported. I can get a list of branches using the 1.0 API but there does not appear to be anything that indicates if they have been merged or not.

      In our workflow we typically use the option to delete branches after they have been merged but occasionally we need to keep the branch for a while or sometimes users simply forget to delete branch. In either case it would be nice to have a way to remind users of any merged branches they have lying around. I was going to write a simple script to do this using the REST API but the merge status is not accessible.

      Can the merge status be added to the API?

      Thanks,
      Phil

            [BCLOUD-14022] Get list of merged branches using REST API

            +1

            Since it is in the webpage, I expected it to be in the API, but does not seem to be so...

            Ted Teichrieb added a comment - Since it is in the webpage, I expected it to be in the API, but does not seem to be so...

            Gail Stewart added a comment - - edited

            I use this git command to find all the branches which have been merged to our "default" branch and create a shell script which I can run from my laptop.  

            git branch -remote --merged origin/dev | egrep -v "main|master|release|dev" | cut -f 2 -d "/" | xargs -I {}  echo "git push origin --delete --no-verify {}; sleep 30s" > delete-merged-branches.sh

            It would seem like Atlassian could automate this so it was a button push or a regularly scheduled task.  

            Another functionality would be to be able to set at the system level the default behavior as deleting branches on merge.  With the option for the committer to override on a case by case basis.

            Gail Stewart added a comment - - edited I use this git command to find all the branches which have been merged to our "default" branch and create a shell script which I can run from my laptop.   git branch -remote --merged origin/dev | egrep -v "main|master|release|dev" | cut -f 2 -d "/" | xargs -I {}  echo "git push origin --delete --no-verify {}; sleep 30s" > delete-merged-branches.sh It would seem like Atlassian could automate this so it was a button push or a regularly scheduled task.   Another functionality would be to be able to set at the system level the default behavior as deleting branches on merge.  With the option for the committer to override on a case by case basis.

            +1

            ethan.jones added a comment - +1

            This must be looked at and implemented. In my case, there are many repositories and most of them have branches that are either very stale or have been merged already. An API to get branches with the last commit date and merge status would be great. The response from the API may contain the details on the changeset as an object because the commit hash is already part of the response.

            AtlassianPro added a comment - This must be looked at and implemented. In my case, there are many repositories and most of them have branches that are either very stale or have been merged already. An API to get branches with the last commit date and merge status would be great. The response from the API may contain the details on the changeset as an object because the commit hash is already part of the response.

            My real goal is to train developers to delete branches once they have been merged to the integration branch.   If there was a configuration setting to expire merged feature branches, that would work too.  I was hoping I could automate some clean up by use the api to get a list of branches merged and older than n days.  Then using that list to delete these older branches.

            Gail Stewart added a comment - My real goal is to train developers to delete branches once they have been merged to the integration branch.   If there was a configuration setting to expire merged feature branches, that would work too.  I was hoping I could automate some clean up by use the api to get a list of branches merged and older than n days.  Then using that list to delete these older branches.

            This would still be a great feature

            Nate Waldrop added a comment - This would still be a great feature

            Arthur V. added a comment -

            Another data available on Web UI is the ahead / behind counts from main branch. It would be nice to have those counts too.

            Arthur V. added a comment - Another data available on Web UI is the ahead / behind counts from main branch . It would be nice to have those counts too.

            In lieu of having this API, which would be uber helpful, it would be really nice to have the ability to set rules for branch pruning directly in Bitbucket. We have a lot of lazy developers that trash up the repo with branches that are no longer needed. I really don't think forcing users to write a script to manage that is a great customer experience.

            Jeff Walter added a comment - In lieu of having this API, which would be uber helpful, it would be really nice to have the ability to set rules for branch pruning directly in Bitbucket. We have a lot of lazy developers that trash up the repo with branches that are no longer needed. I really don't think forcing users to write a script to manage that is a great customer experience.

              Unassigned Unassigned
              a1d2dea23b47 Phil Rittenhouse
              Votes:
              33 Vote for this issue
              Watchers:
              23 Start watching this issue

                Created:
                Updated: