Repository specific pattern for branch names #11881

Closed
opened 2025-11-02 09:50:45 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @sebastian-sauer on GitHub (Oct 18, 2023).

Feature Description

In some environments a branch name pattern is used (like feature/* for all feature branches and bugfix/* for all bugfix branches).
In order to ensure everybody uses the pattern it'd be great to have a setting to configure a branch name regex that must match when pushing a new branch.

If the branch name doesn't match the regex, the push will be rejected.

This could be a configuration option per repository, with .* as default value.

I'd propose to add this to the Repo -> Settings -> Branches page - a mockup for this:

image

Screenshots

No response

Originally created by @sebastian-sauer on GitHub (Oct 18, 2023). ### Feature Description In some environments a branch name pattern is used (like feature/* for all feature branches and bugfix/* for all bugfix branches). In order to ensure everybody uses the pattern it'd be great to have a setting to configure a branch name regex that must match when pushing a new branch. If the branch name doesn't match the regex, the push will be rejected. This could be a configuration option per repository, with .* as default value. I'd propose to add this to the Repo -> Settings -> Branches page - a mockup for this: ![image](https://github.com/go-gitea/gitea/assets/1135157/590e60cb-f22b-429d-9bd9-c1343aef4de5) ### Screenshots _No response_
GiteaMirror added the type/proposal label 2025-11-02 09:50:45 -06:00
Author
Owner

@sebastian-sauer commented on GitHub (Oct 18, 2023):

If the proposal is accepted i'd be happy to create a PR for this.

@sebastian-sauer commented on GitHub (Oct 18, 2023): If the proposal is accepted i'd be happy to create a PR for this.
Author
Owner

@lunny commented on GitHub (Oct 19, 2023):

Please have more discussion before sending PRs.

Maybe rules priority could resolve your problem. Let's say:

1 feature/** can be pushed by some people.
2 ** can not be pushed even if you have write permission.

@lunny commented on GitHub (Oct 19, 2023): Please have more discussion before sending PRs. Maybe rules priority could resolve your problem. Let's say: 1 feature/** can be pushed by some people. 2 ** can not be pushed even if you have write permission.
Author
Owner

@KN4CK3R commented on GitHub (Oct 19, 2023):

Isn't that already possible with the branch rules?

@KN4CK3R commented on GitHub (Oct 19, 2023): Isn't that already possible with the branch rules?
Author
Owner

@delvh commented on GitHub (Oct 19, 2023):

Yes, that should already be possible with branch protection, although with a workaround as you need to invert the logic:
Add branch protection to allow pushes to branch names that match your wanted pattern.
Then, add a wildcard ** that disallows pushes to everything else.

@delvh commented on GitHub (Oct 19, 2023): Yes, that should already be possible with branch protection, although with a workaround as you need to invert the logic: Add branch protection to allow pushes to branch names that match your wanted pattern. Then, add a wildcard `**` that disallows pushes to everything else.
Author
Owner

@sebastian-sauer commented on GitHub (Oct 19, 2023):

Maybe this could be solved. One issue I currently see is that force push will not be allowed on feature branches (as branch protection doesn't allow force push). Or is there an option i currently can't see?

It could be done if https://github.com/go-gitea/gitea/issues/22722 is resolved.

@sebastian-sauer commented on GitHub (Oct 19, 2023): Maybe this could be solved. One issue I currently see is that force push will not be allowed on feature branches (as branch protection doesn't allow force push). Or is there an option i currently can't see? It could be done if https://github.com/go-gitea/gitea/issues/22722 is resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11881