Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-17883

Merging a pull-request without specifying a body overwrites close_source_branch value

    XMLWordPrintable

Details

    Description

      When merging a pull-request, via the Bitbucket REST API, if no body is provided then the original close_source_branch value (on the PR) is both ignored, and overwritten.

      According to the API documentation:

      close_source_branch boolean
      Whether the source branch should be deleted. If this is not provided, we fallback to the value used when the pull request was created, which defaults to False*

      https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests/%7Bpull_request_id%7D/merge

      Steps to replicate

      • Create a pull-request, and specify close_source_branch
      POST https://api.bitbucket.org/2.0/repositories/<owner>/<slug>/pullrequests
      {   ...
          "close_source_branch": true
      }
      
      • Retrieve the pull request - confirm that close_source_branch is still true
      GET https://api.bitbucket.org/2.0/repositories/<owner>/<slug>/pullrequests/<id>
      
      • Merge the PR, without a request body
      POST https://api.bitbucket.org/2.0/repositories/<owner>/<slug>/pullrequests/<id>/merge
      
      • Retrieve the pull request
      GET https://api.bitbucket.org/2.0/repositories/<owner>/<slug>/pullrequests/<id>
      

      Expected: close_source_branch is still true, and the source branch was closed after the merge was completed

      Actual: close_source_branch is overwritten to be false, and the source branch remains open after the merge was completed

      Attachments

        Activity

          People

            Unassigned Unassigned
            786cf2d1368c Mark Tarry
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: