title: How to enforce a format for a (pull request) merge commit message in BitBucket
body: <p>Our team is migrating to BitBucket. Our workflow requires certain formatting for commit messages for code that is merged into the main origin repo.</p>
  
  <p>Each developer has one (or more) fork(s). Our workflow is to push a feature/bug branch to the fork and create a pull request from that branch. Two other devs must review and +1 the pull request before it can be merged.</p>
  
  <p>When someone clicks Merge, BitBucket displays a dialog with the title "Merge Pull Request". At that point, the dev can edit the text message that is logged for the merge before clicking the second Merge button. This is the message that needs to conform to a specific format.</p>
  
  <p>I have read the documentation here: <a href="https://scriptrunner.adaptavist.com/latest/bitbucket/StashMergeChecks.html" rel="noreferrer">https://scriptrunner.adaptavist.com/latest/bitbucket/StashMergeChecks.html</a> It has several very specific examples, but nothing that pertains to our use case. I have not been able to find a good, general-purpose reference for how to create merge checks.</p>
  
  <p>I can write a condition that checks for a specific string value:</p>
  
  <pre><code>mergeRequest.message == "My Message"
  </code></pre>
  
  <p>But I need it to check against a regular expression. 
  How can I write a pre-merge hook to reject the merge if the message doesn't conform to a regex?</p>
  
  <p><strong>Addition</strong></p>
  
  <p>From the documentation, it seems like the condition check script code would be the right place to enforce this condition. The script can be added in <code>Repository Settings &gt; SCRIPTRUNNER &gt; Script Merge Checks &gt; Conditional merge check</code>. There is a long list of examples shown for the conditional merge check, including things like:</p>
  
  <ul>
  <li>Current user in a particular group</li>
  <li>Changed files contains .XYZ files</li>
  <li>Changed files in sensitive directory</li>
  <li>Target branch is release</li>
  </ul>
  
  <p>After some search &amp; experiment I found I could block merges based on the commit message. But so far I have only found examples of comparing entire strings against constant string expressions. I haven't found how to use a regex in this comparison.</p>