mirror of
https://github.com/gogs/gogs.git
synced 2025-10-07 23:21:48 +00:00
api/repo: fix cannot reponse branch with slashes (#4198)
This commit is contained in:
parent
ac8b1e595f
commit
3eb57370a6
@ -32,7 +32,7 @@ func (ctx *APIContext) Error(status int, title string, obj interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if status == 500 {
|
if status == 500 {
|
||||||
log.Error(4, "%s: %s", title, message)
|
log.Error(3, "%s: %s", title, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(status, map[string]string{
|
ctx.JSON(status, map[string]string{
|
||||||
|
@ -258,7 +258,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||||||
m.Get("/forks", repo.ListForks)
|
m.Get("/forks", repo.ListForks)
|
||||||
m.Group("/branches", func() {
|
m.Group("/branches", func() {
|
||||||
m.Get("", repo.ListBranches)
|
m.Get("", repo.ListBranches)
|
||||||
m.Get("/:branchname", repo.GetBranch)
|
m.Get("/*", repo.GetBranch)
|
||||||
})
|
})
|
||||||
m.Group("/keys", func() {
|
m.Group("/keys", func() {
|
||||||
m.Combo("").Get(repo.ListDeployKeys).
|
m.Combo("").Get(repo.ListDeployKeys).
|
||||||
|
@ -7,15 +7,20 @@ package repo
|
|||||||
import (
|
import (
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch
|
// https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch
|
||||||
func GetBranch(ctx *context.APIContext) {
|
func GetBranch(ctx *context.APIContext) {
|
||||||
branch, err := ctx.Repo.Repository.GetBranch(ctx.Params(":branchname"))
|
branch, err := ctx.Repo.Repository.GetBranch(ctx.Params("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetBranch", err)
|
if models.IsErrBranchNotExist(err) {
|
||||||
|
ctx.Error(404, "GetBranch", err)
|
||||||
|
} else {
|
||||||
|
ctx.Error(500, "GetBranch", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user