Also the commit message sent in the curl is not overriding the default commit message added by api. Can we change the priority of this jira and get this fixed asap ? As we are adding automation around this for the whole company and due to this issue it is corrupting the commit messages and merge strategies from the automation.
Merge Pull Request API is not overriding merge strategy
Summary
Using PR merge API doesn't enforce or overrides the "merge_strategy" field, the API follows the default merge strategy set in the repository settings. To add, the API doesn't also overrides the "message" field.
How to reproduce
- Change your repository default merge strategy (under your repository > settings) to "Merge commit"
- Create a new Pull request
- Use the API CURL command below to merge (using "squash") your PR by providing the PR ID Sample CURL command:
curl --request POST \ --url https://api.bitbucket.org/2.0/repositories/username/repositoryurl/pullrequests/pr_Id/merge \ --header 'authorization: Basic <HASH>' \ --header 'cache-control: no-cache' \ --header 'content-type: application/json' \ --data '{ "pullrequest_merge_parameters": { "type": "pullrequest", "message": "Sample commit message", "close_source_branch": "false", "merge_strategy": "squash" } }'
Expected Results
The merge API should overrides / enforce the "merge_strategy" to "squash" the commit set in the API
Actual Results
The merge API is using the default merge strategy set in the repository settings
Workaround
For now, we can manually set the merge strategy in repository settings to change
Official response
Comments (5)
-
-
@Mark Cerezo There are multiple issues here.
- merge_strategy field not being honored.
- message field not being honored
While there is a work-around for the first problem, there is no work-around for the second problem. Could please provide an ETA for the second problem? Independent of the fix, please change your documentation so that other users don't end up discovering the same problem again independently.
-
- changed status to resolved
This happens to be a misinterpretation of our api docs. Try passing in just the value of ‘pullrequest_merge_parameters’.
For example,
--data '{ "type": "pullrequest", "message": "Sample commit message", "close_source_branch": "false", "merge_strategy": "squash" }'
-
- changed status to invalid
-
Note that the
type
of the request body is not "pullrequest" and the "type" element can be omitted.This endpoint is odd in that it isn't restful (the path contains a verb and it doesn't take the same object schema it returns). It's really an RPC endpoint.
@Anna Li-Fatou is right about the layout of the request body.
- Log in to comment
This happens to be a misinterpretation of our api docs. Try passing in just the value of ‘pullrequest_merge_parameters’.
For example,