Skip to content

Commit 0f834f0

Browse files
GiteaBotlunny
andauthored
Allow set branch protection in an empty repository (go-gitea#32095) (go-gitea#32119)
Backport go-gitea#32095 by @lunny Resolve go-gitea#32093 Co-authored-by: Lunny Xiao <[email protected]>
1 parent a3c660f commit 0f834f0

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

routers/web/web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ func registerRoutes(m *web.Route) {
10631063
m.Combo("/edit").Get(repo_setting.SettingsProtectedBranch).
10641064
Post(web.Bind(forms.ProtectBranchForm{}), context.RepoMustNotBeArchived(), repo_setting.SettingsProtectedBranchPost)
10651065
m.Post("/{id}/delete", repo_setting.DeleteProtectedBranchRulePost)
1066-
}, repo.MustBeNotEmpty)
1066+
})
10671067

10681068
m.Group("/tags", func() {
10691069
m.Get("", repo_setting.ProtectedTags)

templates/repo/settings/branches.tmpl

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,17 @@
1515
<form class="tw-flex" action="{{.Link}}" method="post">
1616
{{.CsrfTokenHtml}}
1717
<input type="hidden" name="action" value="default_branch">
18-
{{if not .Repository.IsEmpty}}
19-
<div class="ui dropdown selection search tw-flex-1 tw-mr-2 tw-max-w-96">
20-
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
21-
<input type="hidden" name="branch" value="{{.Repository.DefaultBranch}}">
22-
<div class="default text">{{.Repository.DefaultBranch}}</div>
23-
<div class="menu">
24-
{{range .Branches}}
25-
<div class="item" data-value="{{.}}">{{.}}</div>
26-
{{end}}
27-
</div>
18+
<div class="ui dropdown selection search tw-flex-1 tw-mr-2 tw-max-w-96">
19+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
20+
<input type="hidden" name="branch" value="{{.Repository.DefaultBranch}}">
21+
<div class="default text">{{.Repository.DefaultBranch}}</div>
22+
<div class="menu">
23+
{{range .Branches}}
24+
<div class="item" data-value="{{.}}">{{.}}</div>
25+
{{end}}
2826
</div>
29-
<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.branches.update_default_branch"}}</button>
30-
{{end}}
27+
</div>
28+
<button class="ui primary button"{{if .Repository.IsEmpty}} disabled{{end}}>{{ctx.Locale.Tr "repo.settings.branches.update_default_branch"}}</button>
3129
</form>
3230
</div>
3331

templates/repo/settings/navbar.tmpl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
</a>
1414
{{end}}
1515
{{if .Repository.UnitEnabled $.Context ctx.Consts.RepoUnitTypeCode}}
16-
{{if not .Repository.IsEmpty}}
17-
<a class="{{if .PageIsSettingsBranches}}active {{end}}item" href="{{.RepoLink}}/settings/branches">
18-
{{ctx.Locale.Tr "repo.settings.branches"}}
19-
</a>
20-
{{end}}
16+
<a class="{{if .PageIsSettingsBranches}}active {{end}}item" href="{{.RepoLink}}/settings/branches">
17+
{{ctx.Locale.Tr "repo.settings.branches"}}
18+
</a>
2119
<a class="{{if .PageIsSettingsTags}}active {{end}}item" href="{{.RepoLink}}/settings/tags">
2220
{{ctx.Locale.Tr "repo.settings.tags"}}
2321
</a>

0 commit comments

Comments
 (0)