forked from forgejo/forgejo
GitHub API Compliance (& linting)
This commit is contained in:
parent
71bb6df75a
commit
e6cfccdd40
5 changed files with 61 additions and 9 deletions
|
@ -17,14 +17,26 @@ import (
|
|||
|
||||
// ListIssues list the issues of a repository
|
||||
func ListIssues(ctx *context.APIContext) {
|
||||
issues, err := models.Issues(&models.IssuesOptions{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
Page: ctx.QueryInt("page"),
|
||||
})
|
||||
issueOpts := models.IssuesOptions{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
Page: ctx.QueryInt("page"),
|
||||
IsClosed: ctx.Query("state") == "closed",
|
||||
}
|
||||
|
||||
issues, err := models.Issues(&issueOpts)
|
||||
if err != nil {
|
||||
ctx.Error(500, "Issues", err)
|
||||
return
|
||||
}
|
||||
if ctx.Query("state") == "all" {
|
||||
issueOpts.IsClosed = !issueOpts.IsClosed
|
||||
temp_issues, err := models.Issues(&issueOpts)
|
||||
if err != nil {
|
||||
ctx.Error(500, "Issues", err)
|
||||
return
|
||||
}
|
||||
issues = append(issues, temp_issues...)
|
||||
}
|
||||
|
||||
// FIXME: use IssueList to improve performance.
|
||||
apiIssues := make([]*api.Issue, len(issues))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -141,7 +141,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
|
|||
ctx.JSON(201, repo.APIFormat(&api.Permission{true, true, true}))
|
||||
}
|
||||
|
||||
// Create create one repository of mine
|
||||
// Create one repository of mine
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#create
|
||||
func Create(ctx *context.APIContext, opt api.CreateRepoOption) {
|
||||
// Shouldn't reach this condition, but just in case.
|
||||
|
@ -244,7 +244,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
|
|||
ctx.JSON(201, repo.APIFormat(&api.Permission{true, true, true}))
|
||||
}
|
||||
|
||||
// Get get one repository
|
||||
// Get one repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#get
|
||||
func Get(ctx *context.APIContext) {
|
||||
repo := ctx.Repo.Repository
|
||||
|
@ -266,7 +266,7 @@ func GetByID(ctx *context.APIContext) {
|
|||
ctx.JSON(200, repo.APIFormat(&api.Permission{true, true, true}))
|
||||
}
|
||||
|
||||
// Delete delete one repository
|
||||
// Delete one repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#delete
|
||||
func Delete(ctx *context.APIContext) {
|
||||
owner := ctx.Repo.Owner
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue