Skip to content

Commit 5348573

Browse files
matthiasb85lunny
authored andcommitted
Allow admin users to set a repositoires visibility to public, even if FORCE_PRIVATE is to true (#6541) (#6572)
Signed-off-by: Matthias Beckert <[email protected]>
1 parent 66fa092 commit 5348573

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

routers/repo/setting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
9595
}
9696

9797
visibilityChanged := repo.IsPrivate != form.Private
98-
// when ForcePrivate enabled, you could change public repo to private, but could not change private to public
99-
if visibilityChanged && setting.Repository.ForcePrivate && !form.Private {
98+
// when ForcePrivate enabled, you could change public repo to private, but only admin users can change private to public
99+
if visibilityChanged && setting.Repository.ForcePrivate && !form.Private && !ctx.User.IsAdmin {
100100
ctx.ServerError("Force Private enabled", errors.New("cannot change private repository to public"))
101101
return
102102
}

templates/repo/settings/options.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
<div class="inline field">
2020
<label>{{.i18n.Tr "repo.visibility"}}</label>
2121
<div class="ui checkbox">
22+
{{if .IsAdmin}}
23+
<input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}>
24+
{{else}}
2225
<input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}{{if and $.ForcePrivate .Repository.IsPrivate}} readonly{{end}}>
26+
{{end}}
2327
<label>{{.i18n.Tr "repo.visibility_helper" | Safe}} {{if .Repository.NumForks}}<span class="text red">{{.i18n.Tr "repo.visibility_fork_helper"}}</span>{{end}}</label>
2428
</div>
2529
</div>

0 commit comments

Comments
 (0)