diff options
author | James Cleverley-Prance <jpts@users.noreply.github.com> | 2023-03-16 17:30:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-16 12:30:42 -0500 |
commit | 574d8fe6d6675c8aa05e2b75fdbc01c009efd8be (patch) | |
tree | 4133aa64d1554bc68bfaba65bbfa591a462897ae /routers/api/v1/repo/repo.go | |
parent | 8d9f8e10b10bf7c19c1609072a8cb144176ee01b (diff) | |
download | gitea-574d8fe6d6675c8aa05e2b75fdbc01c009efd8be.tar.gz gitea-574d8fe6d6675c8aa05e2b75fdbc01c009efd8be.zip |
Add absent repounits to create/edit repo API (#23500)
Adds the ability to enable/disable Actions, Packages and Releases from
the API, via the Edit and Get Repository API endpoints.
Diffstat (limited to 'routers/api/v1/repo/repo.go')
-rw-r--r-- | routers/api/v1/repo/repo.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 16608e5bbb..4f43b10259 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -936,6 +936,39 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error { } } + if opts.HasReleases != nil && !unit_model.TypeReleases.UnitGlobalDisabled() { + if *opts.HasReleases { + units = append(units, repo_model.RepoUnit{ + RepoID: repo.ID, + Type: unit_model.TypeReleases, + }) + } else { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeReleases) + } + } + + if opts.HasPackages != nil && !unit_model.TypePackages.UnitGlobalDisabled() { + if *opts.HasPackages { + units = append(units, repo_model.RepoUnit{ + RepoID: repo.ID, + Type: unit_model.TypePackages, + }) + } else { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePackages) + } + } + + if opts.HasActions != nil && !unit_model.TypeActions.UnitGlobalDisabled() { + if *opts.HasActions { + units = append(units, repo_model.RepoUnit{ + RepoID: repo.ID, + Type: unit_model.TypeActions, + }) + } else { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeActions) + } + } + if err := repo_model.UpdateRepositoryUnits(repo, units, deleteUnitTypes); err != nil { ctx.Error(http.StatusInternalServerError, "UpdateRepositoryUnits", err) return err |