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
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue