Skip to content

Commit

Permalink
remove visibility interaction in update action
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiobarkoski committed Aug 9, 2024
1 parent 0586ab6 commit b591e74
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions routers/web/repo/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,7 @@ func SettingsPost(ctx *context.Context) {
form.Private = repo.BaseRepo.IsPrivate || repo.BaseRepo.Owner.Visibility == structs.VisibleTypePrivate
}

visibilityChanged := repo.IsPrivate != form.Private
// when ForcePrivate enabled, you could change public repo to private, but only admin users can change private to public
if visibilityChanged && setting.Repository.ForcePrivate && !form.Private && !ctx.Doer.IsAdmin {
ctx.RenderWithErr(ctx.Tr("form.repository_force_private"), tplSettingsOptions, form)
return
}

repo.IsPrivate = form.Private
if err := repo_service.UpdateRepository(ctx, repo, visibilityChanged); err != nil {
if err := repo_service.UpdateRepository(ctx, repo, false); err != nil {
ctx.ServerError("UpdateRepository", err)
return
}
Expand Down Expand Up @@ -949,6 +941,12 @@ func SettingsPost(ctx *context.Context) {

var err error

// when ForcePrivate enabled, you could change public repo to private, but only admin users can change private to public
if setting.Repository.ForcePrivate && repo.IsPrivate && !ctx.Doer.IsAdmin {
ctx.RenderWithErr(ctx.Tr("form.repository_force_private"), tplSettingsOptions, form)
return
}

if repo.IsPrivate {
err = repo_service.MakeRepoPublic(ctx, repo)
} else {
Expand Down

0 comments on commit b591e74

Please sign in to comment.