sumant sumant - 8 hours ago 2
Git Question

Restrict branch types pushed using Yet Another Commit Checker in Atlassian Stash

The requirement is to set the restrictions such that any new branches pushed to Stash from a developer's machine must follow our naming convention of


"feature/PPT-", "bugfix/PPT-", "hotfix/PPT-", "feature/QC",
"bugfix/QC*", or "hotfix/QC*".


We have Yet Another Commit Checker pre-receive hook enabled and it has an option to restrict using

Branch Regex -

If present, pushes to branches that don't match this regex will be blocked.
What is the format to be used here, to meet my requirement here?
Branch Name Regex

If present, only branches with names that match this regex will be allowed to be created. This affects both new branches being pushed and branches created within the Bitbucket Server UI.

For example,
master|(?:(?:bugfix|hotfix|feature)/[A-Z]+-\d+-.+)
would enforce that pushes should be done to branches that follow the Bitbucket Server Branching Model naming convention.

https://github.com/sford/yet-another-commit-checker

Anyone using this already?

Answer

master|develop|(?:(?:bugfix/QC.|hotfix/QC.|feature/QC.)), master|develop|(?:(?:bugfix/PPT|hotfix/PPT|feature/PPT-.))

This is the entry that needs to go to the Pre-receive hook for branch regex.

This will restrict the push from the developer Stash/Atlassian Sourcetree to branches which doesn't match this requirement.

Example:

Try to push to a branch feature/PPT-Test from the local Atlassian Source tree repo and it works.

However, to push to a branch feature/PPTRandom from the local Atlassian Source tree repo will fail as the regex doesn't match.

It's (dotstar) for wildcard