From 0f834f052bc7b27dd4d1760f485fdd3799f518ce Mon Sep 17 00:00:00 2001 From: Giteabot Date: Tue, 24 Sep 2024 10:42:52 +0800 Subject: [PATCH] Allow set branch protection in an empty repository (#32095) (#32119) Backport #32095 by @lunny Resolve #32093 Co-authored-by: Lunny Xiao --- routers/web/web.go | 2 +- templates/repo/settings/branches.tmpl | 22 ++++++++++------------ templates/repo/settings/navbar.tmpl | 8 +++----- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/routers/web/web.go b/routers/web/web.go index 62613663fd..328be992d4 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1063,7 +1063,7 @@ func registerRoutes(m *web.Route) { m.Combo("/edit").Get(repo_setting.SettingsProtectedBranch). Post(web.Bind(forms.ProtectBranchForm{}), context.RepoMustNotBeArchived(), repo_setting.SettingsProtectedBranchPost) m.Post("/{id}/delete", repo_setting.DeleteProtectedBranchRulePost) - }, repo.MustBeNotEmpty) + }) m.Group("/tags", func() { m.Get("", repo_setting.ProtectedTags) diff --git a/templates/repo/settings/branches.tmpl b/templates/repo/settings/branches.tmpl index 52c0c2c800..6f070ba61c 100644 --- a/templates/repo/settings/branches.tmpl +++ b/templates/repo/settings/branches.tmpl @@ -15,19 +15,17 @@
{{.CsrfTokenHtml}} - {{if not .Repository.IsEmpty}} -
diff --git a/templates/repo/settings/navbar.tmpl b/templates/repo/settings/navbar.tmpl index 414effbf2f..debfad20b7 100644 --- a/templates/repo/settings/navbar.tmpl +++ b/templates/repo/settings/navbar.tmpl @@ -13,11 +13,9 @@ {{end}} {{if .Repository.UnitEnabled $.Context ctx.Consts.RepoUnitTypeCode}} - {{if not .Repository.IsEmpty}} - - {{ctx.Locale.Tr "repo.settings.branches"}} - - {{end}} + + {{ctx.Locale.Tr "repo.settings.branches"}} + {{ctx.Locale.Tr "repo.settings.tags"}}