I cannot see anything wrong with above branches and merges of gitflow process. Please check this document for more information about gitflow process.
There is no direct way to automatically choose different merge strategies based on the source branch. The workaround is that you can use pull request update rest api to set the pr to autoComplete and set the merge strategies according to the source branch. Below is an example for reference.
1, first create a build pipeline and add a powershell task to run below script.
You can check here for steps to create a classic ui pipeline. For yaml pipeline you can check this document.
Below script will set the merge strategy according the the
System.PullRequest.SourceBranch
and enable the autocomplete for this pr. So that the pr will be automatically complete when all the requirements are met. (you need to change the if(){}
part according).
$uri = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.ID)/pullrequests/$(System.PullRequest.PullRequestId)?api-version=5.1"
$response = Invoke-RestMethod -Uri $uri -Headers @{authorization = "Bearer $(System.AccessToken)"} -Method get
$userid = $response.createdBy.id
$merge = "rebaseMerge"
if("$(System.PullRequest.SourceBranch)" -eq "refs/heads/release"){$merge = "noFastForward"}
$body =@{
autoCompleteSetBy = @{
id= "$($userid)"
}
status = "complete"
completionOptions= @{mergeStrategy = $merge}
}
$bjson = $body | ConvertTo-Json
Invoke-RestMethod -Uri $uri -Headers @{authorization = "Bearer $(System.AccessToken)"} -Method patch -ContentType application/json -Body $bjson
2, Then configure the branch policy for Develop branch. and choose the pipeline created above to set up the build validation. By setting up the build validation, the pr will trigger to run the build pipeline which created in above step. And above pipeline will change the merge strategies according to source branch.
You can also submit a feature request (click suggest a feature and choose azure devops)for this facility to Microsoft development.