aboutsummaryrefslogtreecommitdiff
path: root/routers
diff options
context:
space:
mode:
author无闻 <u@gogs.io>2017-06-05 15:34:11 -0400
committerGitHub <noreply@github.com>2017-06-05 15:34:11 -0400
commit51d7f1264bc39a75b4fb016bee7d0f87f8485f3f (patch)
tree63ec5e3eff2ebcbfdc78a4d7649b41a230532e96 /routers
parent3359b942b379bdfb7ae33b8c106c8b3bc8afbf52 (diff)
api: GitHub compliance (#4549)
* Add undocumented endpoint for /repositories/:id * GitHub API Compliance
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/issue.go6
-rw-r--r--routers/api/v1/repo/label.go11
2 files changed, 14 insertions, 3 deletions
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)