From 51d7f1264bc39a75b4fb016bee7d0f87f8485f3f Mon Sep 17 00:00:00 2001 From: 无闻 Date: Mon, 5 Jun 2017 15:34:11 -0400 Subject: api: GitHub compliance (#4549) * Add undocumented endpoint for /repositories/:id * GitHub API Compliance --- routers/api/v1/repo/issue.go | 6 ++++-- routers/api/v1/repo/label.go | 11 ++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'routers/api') diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 4a072633..d6ae7b4d 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -47,6 +47,7 @@ func ListUserIssues(c *context.APIContext) { opts := models.IssuesOptions{ AssigneeID: c.User.ID, Page: c.QueryInt("page"), + IsClosed: api.StateType(c.Query("state")) == api.STATE_CLOSED, } listIssues(c, &opts) @@ -54,8 +55,9 @@ func ListUserIssues(c *context.APIContext) { func ListIssues(c *context.APIContext) { opts := models.IssuesOptions{ - RepoID: c.Repo.Repository.ID, - Page: c.QueryInt("page"), + RepoID: c.Repo.Repository.ID, + Page: c.QueryInt("page"), + IsClosed: api.StateType(c.Query("state")) == api.STATE_CLOSED, } listIssues(c, &opts) 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) -- cgit v1.2.3