Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,9 @@ func RegisterRoutes(m *macaron.Macaron) {
Delete(reqToken(), reqRepoWriter(models.UnitTypeReleases), repo.DeleteReleaseAttachment)
})
})
m.Group("/tags", func() {
m.Get("/:tag", repo.GetReleaseTag)
})
}, reqRepoReader(models.UnitTypeReleases))
m.Post("/mirror-sync", reqToken(), reqRepoWriter(models.UnitTypeCode), repo.MirrorSync)
m.Get("/editorconfig/:filename", context.RepoRef(), reqRepoReader(models.UnitTypeCode), repo.GetEditorconfig)
Expand Down
54 changes: 54 additions & 0 deletions routers/api/v1/repo/release_tags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package repo

import (
"net/http"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
)

// GetReleaseTag get a single release of a repository by its tagname
func GetReleaseTag(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/releases/tags/{tag} repository repoGetReleaseTag
// ---
// summary: Get a release by tagname
// produces:
// - application/json
// parameters:
// - name: owner
// in: path
// description: owner of the repo
// type: string
// required: true
// - name: repo
// in: path
// description: name of the repo
// type: string
// required: true
// - name: tag
// in: path
// description: tagname of the release to get
// type: string
// required: true
// responses:
// "200":
// "$ref": "#/responses/Release"

tag := ctx.Params(":tag")

release, err := models.GetRelease(ctx.Repo.Repository.ID, tag)
if err != nil {
ctx.Error(http.StatusNotFound, "GetRelease", err)
return
}

if err := release.LoadAttributes(); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}
ctx.JSON(http.StatusOK, release.APIFormat())
}
40 changes: 40 additions & 0 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7569,6 +7569,46 @@
}
}
},
"/repos/{owner}/{repo}/releases/tags/{tag}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Get a release by tagname",
"operationId": "repoGetReleaseTag",
"parameters": [
{
"type": "string",
"description": "owner of the repo",
"name": "owner",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repo",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "tagname of the release to get",
"name": "tag",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/Release"
}
}
}
},
"/repos/{owner}/{repo}/releases/{id}": {
"get": {
"produces": [
Expand Down