Commit checker is not respected when merging a commit via a pull-request.
- Create and clone a new repo locally
- In Bitbucket go to Settings -> Hooks
- “Enable” the Simple Bitbucket Commit Checker
- Go all the way to the bottom and click
- Click on “New rule Group”
- Matching commits are “Accepted”
- The group matches a commit if “no rules match”
- Click on “New Rule”
- For the regex to match type in something like “OOPS”
- Add a message to the commiter: “Please remove OOPS from commit message”
- Save the hook
What happens if you leave the branch field empty to work on all branches. Then the hook prevents the push to the branches.
For sake of arguement why would you disallow this for only master? We have our reviewers listed out in the commit message. Our default commit message template fills out the default commit message with the words “Reviewed by NOBODY (OOPS!)” as there is no reviewer until after it goes through code review.
We use the commit checker to make sure the worrd “OOPS” is not in any commit message when commiting to master or release branches.
What exactly do you mean by "Then the hook prevents the push to the branches."?
Are you saying that you want to use the hook only on master-branch?
What exactly do you mean by "Then the hook prevents the push to the branches."? Are you saying that you want to use the hook only on master-branch?
That's exactly right.
Please note it is possible now to set a hook to only run on master but the main point here is that when you use a Pull Request to merge your changes from branch x => master that hook is not respected.
I anticipate bitbucket is not running the commits through the commit checker at PR-merge-time.
Cannot reproduce using Bitbucket Server v. 5.8.2. Feel free to close unless anyone else can repro.