aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/label.go
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2016-10-07 19:17:27 +0200
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2016-12-02 09:18:15 +0100
commite6cfccdd40397b95dcf3de0ea9b484feea954fc2 (patch)
tree8c758b622b022ffae542bf4caf3eb9c8623bd317 /routers/api/v1/repo/label.go
parent71bb6df75ae541687c64f5e6e4da16ea9e95acfe (diff)
downloadgitea-e6cfccdd40397b95dcf3de0ea9b484feea954fc2.tar.gz
gitea-e6cfccdd40397b95dcf3de0ea9b484feea954fc2.zip
GitHub API Compliance (& linting)
Diffstat (limited to 'routers/api/v1/repo/label.go')
-rw-r--r--routers/api/v1/repo/label.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go
index 383868beda..a2bf3a9e40 100644
--- a/routers/api/v1/repo/label.go
+++ b/routers/api/v1/repo/label.go
@@ -5,6 +5,8 @@
package repo
import (
+ "strconv"
+
api "code.gitea.io/sdk/gitea"
"code.gitea.io/gitea/models"
@@ -28,7 +30,16 @@ func ListLabels(ctx *context.APIContext) {
// GetLabel get label by repository and label id
func GetLabel(ctx *context.APIContext) {
- label, err := models.GetLabelInRepoByID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
+ var (
+ label *models.Label
+ err error
+ )
+ strID := ctx.Params(":id")
+ if intID, err2 := strconv.ParseInt(strID, 10, 64); err2 != nil {
+ label, err = models.GetLabelInRepoByName(ctx.Repo.Repository.ID, strID)
+ } else {
+ label, err = models.GetLabelInRepoByID(ctx.Repo.Repository.ID, intID)
+ }
if err != nil {
if models.IsErrLabelNotExist(err) {
ctx.Status(404)