1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Fix API-Endpoint release (#3012)

* Fixes API-Endpoint release (#3005)

* Using context.ReferencesGitRepo(); doing the same in the PATCH route.

* Add release create, get and update test
This commit is contained in:
Marc Brückner
2018-01-16 09:54:13 +01:00
committed by Lauris BH
parent cc0c4a30a7
commit 695b10bedd
3 changed files with 91 additions and 3 deletions

View File

@@ -96,7 +96,7 @@ func ListReleases(ctx *context.APIContext) {
// CreateRelease create a release
func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
// swagger:operation GET /repos/{owner}/{repo}/releases repository repoCreateRelease
// swagger:operation POST /repos/{owner}/{repo}/releases repository repoCreateRelease
// ---
// summary: Create a release
// consumes:
@@ -146,6 +146,7 @@ func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
IsDraft: form.IsDraft,
IsPrerelease: form.IsPrerelease,
IsTag: false,
Repo: ctx.Repo.Repository,
}
if err := models.CreateRelease(ctx.Repo.GitRepo, rel, nil); err != nil {
if models.IsErrReleaseAlreadyExist(err) {
@@ -167,6 +168,8 @@ func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
rel.IsPrerelease = form.IsPrerelease
rel.PublisherID = ctx.User.ID
rel.IsTag = false
rel.Repo = ctx.Repo.Repository
rel.Publisher = ctx.User
if err = models.UpdateRelease(ctx.Repo.GitRepo, rel, nil); err != nil {
ctx.ServerError("UpdateRelease", err)