4

We use bitbucket server as our source repository. I'm not sure if that is relevant to this if it can be solved with a vanilla git hook.

We have the current workflow:

Developer commits to a branch, creates a pull request. Reviewers reply with feedback to code, and developer proceeds to make 'fix' commits based on feedback which will eventually be rebased away after the branch is approved. This allows the reviewers to click on the commit and see diffs between the original pr (which they already reviewed) and the change based on feedback. In order to make it easy for reviewers to distinguish, fix commits all have the prefix 'FIXUP' in their commit message.

This workflow works really well for us, however sometimes the developer will forget to rebase the fixup commits into their branch and we end with our master branch having a bunch of commit messages titled FIXUP:...

Is it possible to write a hook that prevents merges to master where there are commits with messages starting with a certain string? In addition, is it also possible to make this evident in bitbucket's ui?

EDIT: Between GlennV's answer and git hook: ensure each merge into the master has a message also the automatic merges I think I can get some working, thanks everyone!

Community
  • 1
  • 1
ashishsc
  • 43
  • 4
  • It's possible to write such hooks. Whether you can get them to *run* on bitbucket (or any other hosting site) is another matter entirely, and I don't know the answer to that one. – torek Jun 16 '16 at 00:46
  • Bitbucket's web hooks are described here, https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html. Should be possible. This is the exact kind of thing these hooks are for. – David Neiss Jun 16 '16 at 01:26

1 Answers1

1

You can implement custom prehooks that will be run on Bitbucket server using the (commercial) Script Runner add-on.

It has a number of "pre-receive hook" scripts built-in that will be executed on Bitbucket when someone does a push and depending on the outcome the push is accepted or rejected and the person who executes the push gets a message describing possible problems. You can also implement your own "pre-receive hook" scripts in Groovy.

We have a bunch of custom logic implemented in our own scripts, so it's definitely possible to get the behaviour you're looking for.

GlennV
  • 3,471
  • 4
  • 26
  • 39