Reputation: 606
I want to enable GitHub branch protection on all branches except those prefixed with "private_", for example. This way, we do not have to enable every new 'non private' branch as it is created.
I cannot find a way, using GitHub's pattern matching/globbing rules, to accomplish this. Something like a "/^private*/" rule would be ideal. Unfortunately, we do not enforce naming conventions, so a "common-prefix*" rule wouldn't help here.
Does anyone know of a way to do this, in the GUI branch protection rules, not via the API?
Thanks in advance!
Upvotes: 4
Views: 6629
Reputation: 61
Using **\**
as the last branch protection rule applies the branch protection rules for all the branches which do not fall into any of the mentioned branch protection rules.
For example if you have these branches - users-1, users-2, releases-1, releases-2, temp-1, temp2, random
then, branch protections like the below would set:
users-*
--> would cover users-1, users-2
releases-*
--> would cover releases-1, releases-2
**\**
--> would cover everything else temp-1, temp2, random
Upvotes: 4
Reputation: 967
Protected branch rules use patterns from the fnmatch syntax.
They don't work as RegExp expressions, so it's not possible to apply a lookahead expression to match only branches that not start with private_
.
What you can do is to apply a prefix for protected branches. For example, all branches named protected_
(or public_
) would be the protected.
So you'd need the rule protected_*
Demo: https://repl.it/@herodrigues/LopsidedAwfulPortablesoftware
Upvotes: 0