Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Hook on branch creation to record 'parent' branch name that new branch was created from?

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

2 answers

1 accepted

0 votes
Answer accepted
Mikael Sandberg Community Leader Feb 11, 2020

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.

Mikael Sandberg Community Leader Feb 11, 2020

Bitbucket does not store that information, what the Branch from is used for is to get the latest commit on that 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 we@reconquest.io.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

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...

485 views 5 4
Read article

Community Events

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

Events near you