-
Suggestion
-
Resolution: Unresolved
-
None
-
7
-
There is a undocumented way (below) to determine if a branch is configured to auto-merge in branch modelling using REST API. This information can help developers to use scripts to control their branches.
It should be documented.
Workaround:
There is a method for determining, and changing the Auto Merge State of a repository. This is an internal REST API that we don't have published. It hasn't been refined for public use, but it should work for what you're looking for.
Get Auto Merge Current State
curl -v -u <USER_NAME>:<PASSWORD> -X GET -H "Content-Type: application/json" "http://localhost:7990/bitbucket/rest/branch-utils/1.0/projects/{PROJECT_KEY}/repos/{REPO_SLUG}/automerge/enabled"
A return code of 404 indicates that Auto Merge is Disabled
Response: Auto Merge Not Enabled
> Content-Type: application/json > < HTTP/1.1 404 Not Found < Server: Apache-Coyote/1.1
A return code of 200 indicated that Auto Merge is Enabled
Response: Auto Merge Enabled
< HTTP/1.1 200 < X-AREQUESTID: @4KCVEWx1043x453x0
This is true even if the repository is enabled/ disabled at the project level.
Enable Auto Merge
curl -v -u <USER_NAME>:<PASSWORD> -X POST -H "Content-Type: application/json" "http://localhost:7990/bitbucket/rest/branch-utils/1.0/projects/{PROJECT_KEY}/repos/{REPO_SLUG}/automerge/enabled"
Disable Auto Merge
curl -v -u <USER_NAME>:<PASSWORD> -X DELETE -H "Content-Type: application/json" "http://localhost:7990/bitbucket/rest/branch-utils/1.0/projects/{PROJECT_KEY}/repos/{REPO_SLUG}/automerge/enabled"
- is related to
-
BSERV-5411 Set branching model using REST API
- Gathering Interest
-
BSERV-7284 Promote branch model API to public API
- Gathering Interest