diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-05-06 17:39:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-06 17:39:06 +0800 |
commit | e5a8ebc0ed2553a16bac4b54a74cc3e5e8036b32 (patch) | |
tree | c26686d3793d3908c9f55a11be242103ff1ea04b /routers/api | |
parent | 0ebabf3c6b12a0c3fe8f54398b4bb5a1d2cbeebf (diff) | |
download | gitea-e5a8ebc0ed2553a16bac4b54a74cc3e5e8036b32.tar.gz gitea-e5a8ebc0ed2553a16bac4b54a74cc3e5e8036b32.zip |
Require at least one unit to be enabled (#24189)
Don't remember why the previous decision that `Code` and `Release` are
non-disable units globally. Since now every unit include `Code` could be
disabled, maybe we should have a new rule that the repo should have at
least one unit. So any unit could be disabled.
Fixes #20960
Fixes #7525
---------
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: yp05327 <576951401@qq.com>
Diffstat (limited to 'routers/api')
-rw-r--r-- | routers/api/v1/repo/repo.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 48ace3a8e0..36cc03f893 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -970,9 +970,11 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error { } } - if err := repo_model.UpdateRepositoryUnits(repo, units, deleteUnitTypes); err != nil { - ctx.Error(http.StatusInternalServerError, "UpdateRepositoryUnits", err) - return err + if len(units)+len(deleteUnitTypes) > 0 { + if err := repo_model.UpdateRepositoryUnits(repo, units, deleteUnitTypes); err != nil { + ctx.Error(http.StatusInternalServerError, "UpdateRepositoryUnits", err) + return err + } } log.Trace("Repository advanced settings updated: %s/%s", owner.Name, repo.Name) |