diff options
author | Marc Brückner <marc@ma-br.de> | 2018-01-16 09:54:13 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2018-01-16 10:54:13 +0200 |
commit | 695b10beddc640d333fd5864cb6edb03e540b344 (patch) | |
tree | 8bf0e4da05f6fc8b5303780abfe2b36bccf4f8bd /routers | |
parent | cc0c4a30a778b27393923d29fe97b8bc33f345f4 (diff) | |
download | gitea-695b10beddc640d333fd5864cb6edb03e540b344.tar.gz gitea-695b10beddc640d333fd5864cb6edb03e540b344.zip |
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
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/api.go | 4 | ||||
-rw-r--r-- | routers/api/v1/repo/release.go | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 8a300f9958..6bbc014266 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -463,9 +463,9 @@ func RegisterRoutes(m *macaron.Macaron) { }) m.Group("/releases", func() { m.Combo("").Get(repo.ListReleases). - Post(reqToken(), reqRepoWriter(), bind(api.CreateReleaseOption{}), repo.CreateRelease) + Post(reqToken(), reqRepoWriter(), context.ReferencesGitRepo(), bind(api.CreateReleaseOption{}), repo.CreateRelease) m.Combo("/:id").Get(repo.GetRelease). - Patch(reqToken(), reqRepoWriter(), bind(api.EditReleaseOption{}), repo.EditRelease). + Patch(reqToken(), reqRepoWriter(), context.ReferencesGitRepo(), bind(api.EditReleaseOption{}), repo.EditRelease). Delete(reqToken(), reqRepoWriter(), repo.DeleteRelease) }) m.Post("/mirror-sync", reqToken(), reqRepoWriter(), repo.MirrorSync) diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go index f5b529ac6a..41efa482dd 100644 --- a/routers/api/v1/repo/release.go +++ b/routers/api/v1/repo/release.go @@ -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) |