sumant sumant - 10 months ago 76
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,
would enforce that pushes should be done to branches that follow the Bitbucket Server Branching Model naming convention.

Anyone using this already?

Answer Source

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.


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download