0

Gitflow workflow states that Hotfix branches will be merged to both Develop and Master branches. Since engineers forgot more than once to merge their hotfix to Develop, I want to mandate that the merge to develop is done first. How can I configure Bitbucket to block merges of commits, that do not already exist in Develop, to master?

Maor
  • 650
  • 1
  • 6
  • 13

1 Answers1

1

I don't know about BitBucket, but if you're able to install your own hooks, it's easy enough to script whatever you want in a pre-recive or update hook.

The following is an (untested) example, there are perhaps more efficient git commands to accomplish this, I'm not sure.

#!/bin/bash
# ... << Code to set up your hook variables here >>> ...

if [ "$(git branch Develop --contains $new_rev | wc -l)" -eq 0 ]; then
    echo "ERROR: You must commit to Develop first and then merge"
    exit 1
fi
exit 0
Mort
  • 3,379
  • 1
  • 25
  • 40
  • 1
    You can indeed install your own server-side hooks in Bitbucket Server. It's not encouraged, since it's somewhat opaque (easy to install hooks, forget about them, then have users or future admins going down a troubleshooting rabbit hole for days or weeks). Read [How to create a simple hook in Bitbucket Server](https://confluence.atlassian.com/bitbucketserverkb/how-to-create-a-simple-hook-in-bitbucket-server-779171711.html) (skip past the stuff about Java hooks, it describes basic script hooks further down). – daveruinseverything Jun 10 '18 at 01:50