Skip to content

Restrict branch naming when new change matches with protection rules#36405

Merged
silverwind merged 5 commits into
go-gitea:mainfrom
kemzeb:fix/rename-branch
Jan 23, 2026
Merged

Restrict branch naming when new change matches with protection rules#36405
silverwind merged 5 commits into
go-gitea:mainfrom
kemzeb:fix/rename-branch

Conversation

@kemzeb
Copy link
Copy Markdown
Member

@kemzeb kemzeb commented Jan 18, 2026

Resolves #36381 by only allowing admins to perform branch renames that match to branch protection rules.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 18, 2026
"repo.branch.renamed": "Branch %s was renamed to %s.",
"repo.branch.rename_default_or_protected_branch_error": "Only admins can rename default or protected branches.",
"repo.branch.rename_protected_branch_failed": "This branch is protected by glob-based protection rules.",
"repo.branch.rename_protected_branch_failed": "Failed to rename branch due to branch protection rules.",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this change as this error may cover both static and glob-based protection rules.

Comment thread services/repository/branch.go Outdated
@kemzeb kemzeb marked this pull request as draft January 19, 2026 03:13
@kemzeb kemzeb marked this pull request as ready for review January 19, 2026 03:29
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 22, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 23, 2026
@lunny lunny added type/bug reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Jan 23, 2026
@silverwind silverwind merged commit 56c5d5e into go-gitea:main Jan 23, 2026
24 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Jan 23, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jan 23, 2026
silverwind added a commit to silverwind/gitea that referenced this pull request Jan 23, 2026
* origin/main:
  Bugfix: Potential incorrect runID in run status update (go-gitea#36437)
  Restrict branch naming when new change matches with protection rules (go-gitea#36405)
  Refactor GetRepoRawDiffForFile to avoid unnecessary pipe or goroutine (go-gitea#36434)
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jan 26, 2026
* giteaofficial/main:
  Normalize guessed languages for code highlighting (go-gitea#36450)
  Add `knip` linter (go-gitea#36442)
  Fix various bugs (go-gitea#36446)
  Update tool dependencies (go-gitea#36445)
  Update JS dependencies, adjust webpack config, misc fixes (go-gitea#36431)
  fix: Improve image captcha contrast for dark mode (go-gitea#36265)
  Refactor template render (go-gitea#36438)
  Add documentation for markdown anchor post-processing (go-gitea#36443)
  Fix markup heading parsing, fix emphasis parsing (go-gitea#36284)
  Front port changelog for 1.25.4 (go-gitea#36432)
  Bugfix: Potential incorrect runID in run status update (go-gitea#36437)
  Restrict branch naming when new change matches with protection rules (go-gitea#36405)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Apr 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Branch Protection Not Enforcing When Renaming Branches

5 participants