Branch protection with regex pattern #10997

Open
opened 2025-11-02 09:24:22 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @panangam on GitHub (Jun 9, 2023).

Feature Description

It would be great if we can use regex to specify branch name patterns for branch protection. It is a more powerful syntax than glob, for example, when using variable length patterns.

Use case-wise, maybe having a checkbox to select between a glob pattern or a regex pattern.

Screenshots

No response

Originally created by @panangam on GitHub (Jun 9, 2023). ### Feature Description It would be great if we can use regex to specify branch name patterns for branch protection. It is a more powerful syntax than glob, for example, when using variable length patterns. Use case-wise, maybe having a checkbox to select between a glob pattern or a regex pattern. ### Screenshots _No response_
GiteaMirror added the type/proposal label 2025-11-02 09:24:22 -06:00
Author
Owner

@wolfogre commented on GitHub (Jun 9, 2023):

I'm not sure if we really need regex for branch name matching, and I have a similar question: why doesn't .gitignore support syntax? I mean file names could be more complex then branch names.

@wolfogre commented on GitHub (Jun 9, 2023): I'm not sure if we really need regex for branch name matching, and I have a similar question: why doesn't `.gitignore` support syntax? I mean file names could be more complex then branch names.
Author
Owner

@lunny commented on GitHub (Jun 9, 2023):

Do you have any case the glob cannot satisfy?

@lunny commented on GitHub (Jun 9, 2023): Do you have any case the glob cannot satisfy?
Author
Owner

@panangam commented on GitHub (Jun 9, 2023):

Do you have any case the glob cannot satisfy?

For example, I want to limit only certain users to push new branches named "hotfix/..." followed by alphanumeric characters, for example "hotfix/test1", but not "hotfix/test1/test2". With regex I can do

^hotfix/[a-zA-Z0-9]+$

I don't think this is possible with a glob pattern. Am I wrong?

@panangam commented on GitHub (Jun 9, 2023): > Do you have any case the glob cannot satisfy? For example, I want to limit only certain users to push new branches named "hotfix/..." followed by alphanumeric characters, for example "hotfix/test1", but not "hotfix/test1/test2". With regex I can do ```regex ^hotfix/[a-zA-Z0-9]+$ ``` I don't think this is possible with a glob pattern. Am I wrong?
Author
Owner

@lunny commented on GitHub (Jun 9, 2023):

hotfix/*?

@lunny commented on GitHub (Jun 9, 2023): `hotfix/*`?
Author
Owner

@stevapple commented on GitHub (Sep 24, 2024):

I have a set of rules for main and release/**, but I haven’t figured out how to match all the other branches with glob. I know that Gitea will only use the first matched rule, but sadly it didn’t provide a way to adjust rule order.

@stevapple commented on GitHub (Sep 24, 2024): I have a set of rules for `main` and `release/**`, but I haven’t figured out how to match all the other branches with `glob`. I know that Gitea will only use the first matched rule, but sadly it didn’t provide a way to adjust rule order.
Author
Owner

@lunny commented on GitHub (Sep 24, 2024):

I have a set of rules for main and release/**, but I haven’t figured out how to match all the other branches with glob. I know that Gitea will only use the first matched rule, but sadly it didn’t provide a way to adjust rule order.

About the rule order, that should be another topic which I would like to support.

@lunny commented on GitHub (Sep 24, 2024): > I have a set of rules for `main` and `release/**`, but I haven’t figured out how to match all the other branches with `glob`. I know that Gitea will only use the first matched rule, but sadly it didn’t provide a way to adjust rule order. About the rule order, that should be another topic which I would like to support.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10997