diff options
Diffstat (limited to 'routers/api/v1/repo/label.go')
-rw-r--r-- | routers/api/v1/repo/label.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go index 289f40a4..1161d633 100644 --- a/routers/api/v1/repo/label.go +++ b/routers/api/v1/repo/label.go @@ -5,6 +5,8 @@ package repo import ( + "github.com/Unknwon/com" + api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/models" @@ -26,7 +28,14 @@ func ListLabels(c *context.APIContext) { } func GetLabel(c *context.APIContext) { - label, err := models.GetLabelOfRepoByID(c.Repo.Repository.ID, c.ParamsInt64(":id")) + var label *models.Label + var err error + idStr := c.Params(":id") + if id := com.StrTo(idStr).MustInt64(); id > 0 { + label, err = models.GetLabelOfRepoByID(c.Repo.Repository.ID, id) + } else { + label, err = models.GetLabelOfRepoByName(c.Repo.Repository.ID, idStr) + } if err != nil { if models.IsErrLabelNotExist(err) { c.Status(404) |