We have a large team working on several releases at once. We use Bitbucket to create branches, pull requests for merging and auto-merge to merge forward to future release branches. We need a way to ensure that branches created from a release branch can only be merged to that release branch in a pull request.
One thought is to have a hook on branch creation that adds the 'parent' branch name to the new branch's description. Then another hook on pull request creation that verifies the destination branch matches the parent branch, or perhaps modifies the destination list to only include the parent release branch. This would also have to exempt release to release and release to develop merges triggered by the auto-merge
Hi @Mike Rago,
Welcome to Atlassian Community.
Git does not store the parent a branch was branched off from, to Git branches are just pointers to specific commits. So the closest you can get is to see if pushed commits are ancestors of a commit on the branch you are pushing to. Take a look at How to find the nearest parent of a Git branch? for more information and solutions.
Thanks Mikael for the quick response and the link. I understand how Git stores branches. I was wondering if Bitbucket itself could be used to gather the info needed. When we create a branch in Bitbucket, we have to select the "Branch from" branch. I am wondering if at this point we can get the "from branch" from Bitbucket and add it to the new branch's description. We could then use this info in a pull request hook to verify that we are merging into the correct release branch.
Hello @Mike Rago
I'm one of mainteiners of External Hooks Add-on for Bitbucket.
It supports both pre-receive & merge check hooks, so you can implement branch checking logic here easily.
By using merge check you can ensure that target branch is going to be merged into release branch with couple of git commands in bash script.
We will be happy to help you with configuration, just drop us an e-mail at email@example.com.
Hi everyone, We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events