Apply a single branch protection rule to both master and release-*

I’d like to apply a single branch protection rule to both master and release-*. Is there a way to do that in the Apply rule to input box?

9 Likes

No, there isn’t a way to do that in the “Apply rule to” box. As stated in the protected branches documentation, we use the fnmatch library to match branch names to the match expression. There is a feature that would allow for matching two rules like that if there is a flag enabled but we don’t enable that flag in our environment.

Can you enable the flag?

But generally, the technical details of the current solution aren’t so interesting. I’m sure a solution exists.

This library is used in much more than just matching branch names for protected branches. Enabling the flag could have far-reaching impacts and performance implications across the entire code base. So it is highly unlikely that we would be able to enable the flag.

However, I’ll pass along the request.

To clarify, my request is not to enable the flag, is it to apply a single branch protection rule to both master and release-*.

Like I said, the details of why it can or cannot be done with the current solution are not so interesting. I’m sure a solution exists.

5 Likes

I don’t get how this is better? Unless I’m missing something, now I can’t pretect, dev, staging and master from force pushes. Why would you impose this? Please, help me understand.

Never mind…  I see that I can create multiple rules. Thank you.

Hi Justin, how do you do multiple rules?

2 Likes

Please share how you managed to do this @justincbeck  😞

Ah! You just have to go back to the Branches settings page and you can add another rule. Can’t believe I missed that.

3 Likes

See below (or above) just go back to the branches page and add another rule. That’s the easiest way.