]> source.dussan.org Git - gitea.git/commitdiff
Allow set branch protection in an empty repository (#32095)
authorLunny Xiao <xiaolunwen@gmail.com>
Tue, 24 Sep 2024 02:06:28 +0000 (10:06 +0800)
committerGitHub <noreply@github.com>
Tue, 24 Sep 2024 02:06:28 +0000 (02:06 +0000)
routers/web/web.go
templates/repo/settings/branches.tmpl
templates/repo/settings/navbar.tmpl

index 5129bd4bda39c694567a3cec1fe3ddfa897ee3f7..af46c36fe7d2b616f5d7c66ead3eecebd514fce8 100644 (file)
@@ -1069,7 +1069,7 @@ func registerRoutes(m *web.Router) {
                        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)
index 52c0c2c800b688d76951d65913d91c43fb2db8e6..6f070ba61cd0f32aa2c4bf29d1511a0507c5effe 100644 (file)
                                <form class="tw-flex" action="{{.Link}}" method="post">
                                        {{.CsrfTokenHtml}}
                                        <input type="hidden" name="action" value="default_branch">
-                                       {{if not .Repository.IsEmpty}}
-                                               <div class="ui dropdown selection search tw-flex-1 tw-mr-2 tw-max-w-96">
-                                                       {{svg "octicon-triangle-down" 14 "dropdown icon"}}
-                                                       <input type="hidden" name="branch" value="{{.Repository.DefaultBranch}}">
-                                                       <div class="default text">{{.Repository.DefaultBranch}}</div>
-                                                       <div class="menu">
-                                                               {{range .Branches}}
-                                                                       <div class="item" data-value="{{.}}">{{.}}</div>
-                                                               {{end}}
-                                                       </div>
+                                       <div class="ui dropdown selection search tw-flex-1 tw-mr-2 tw-max-w-96">
+                                               {{svg "octicon-triangle-down" 14 "dropdown icon"}}
+                                               <input type="hidden" name="branch" value="{{.Repository.DefaultBranch}}">
+                                               <div class="default text">{{.Repository.DefaultBranch}}</div>
+                                               <div class="menu">
+                                                       {{range .Branches}}
+                                                               <div class="item" data-value="{{.}}">{{.}}</div>
+                                                       {{end}}
                                                </div>
-                                               <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.branches.update_default_branch"}}</button>
-                                       {{end}}
+                                       </div>
+                                       <button class="ui primary button"{{if .Repository.IsEmpty}} disabled{{end}}>{{ctx.Locale.Tr "repo.settings.branches.update_default_branch"}}</button>
                                </form>
                        </div>
 
index b9105bb8ed8a4a2c5ad305955112b1922cdff4f2..e46273aff055f9b713ccfd4db7f3b251f83ee95f 100644 (file)
                        </a>
                {{end}}
                {{if .Repository.UnitEnabled $.Context ctx.Consts.RepoUnitTypeCode}}
-                       {{if not .Repository.IsEmpty}}
-                               <a class="{{if .PageIsSettingsBranches}}active {{end}}item" href="{{.RepoLink}}/settings/branches">
-                                       {{ctx.Locale.Tr "repo.settings.branches"}}
-                               </a>
-                       {{end}}
+                       <a class="{{if .PageIsSettingsBranches}}active {{end}}item" href="{{.RepoLink}}/settings/branches">
+                               {{ctx.Locale.Tr "repo.settings.branches"}}
+                       </a>
                        <a class="{{if .PageIsSettingsTags}}active {{end}}item" href="{{.RepoLink}}/settings/tags">
                                {{ctx.Locale.Tr "repo.settings.tags"}}
                        </a>