Allow set branch protection in an empty repository (#32095)

pull/32072/head^2
Lunny Xiao 2 months ago committed by GitHub
parent 3f2d8f8730
commit 6eb5950835
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      routers/web/web.go
  2. 4
      templates/repo/settings/branches.tmpl
  3. 2
      templates/repo/settings/navbar.tmpl

@ -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)

@ -15,7 +15,6 @@
<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}}">
@ -26,8 +25,7 @@
{{end}}
</div>
</div>
<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.branches.update_default_branch"}}</button>
{{end}}
<button class="ui primary button"{{if .Repository.IsEmpty}} disabled{{end}}>{{ctx.Locale.Tr "repo.settings.branches.update_default_branch"}}</button>
</form>
</div>

@ -13,11 +13,9 @@
</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 .PageIsSettingsTags}}active {{end}}item" href="{{.RepoLink}}/settings/tags">
{{ctx.Locale.Tr "repo.settings.tags"}}
</a>

Loading…
Cancel
Save