Gerrit does support Regex matching, hence, we can setup control on the type of Branch names the Developers choose to create branch names. For Example, if we are to allow only Branch names that start with dev_ :
^refs/heads/dev_* regular expression match
Applies to all references that match the expression.
Gerrit relies on the ^ prefix to activate regex matching.
The ^ prefix is also part of the pattern, and therefore always anchors to the start.
Few more things to keep in mind regarding Gerrit Permissions:
For refs/heads/QA/master Gerrit tries rules in the following order, until it has a decision:
1) refs/heads/QA/master exact match, wins
2) refs/heads/QA/* glob wildcard, longest common prefix
3) refs/heads/* glob wildcard, common prefix
4) refs/* glob wildcard, common prefix
For regular expressions “most specific” is more complicated to evaluate.
^refs/heads/QA/.*
^refs/heads/QA/stable-[0-9.]+
The 2nd rule is more specific, as it matches fewer possible strings.
Most Specific First
For example in Global Configuration, if we have:
Result for refs/heads/master
-2..+2 Administrators
+0..+2 CI Server refs/heads/* rule also matches!
Result for refs/heads/next
-1..+1 Administrators
+0..+2 CI Server