diff options
Diffstat (limited to 'routers/api/v1/repo/branch.go')
-rw-r--r-- | routers/api/v1/repo/branch.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index 489fbe6b4e..aed630f558 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -15,7 +15,14 @@ import ( // GetBranch get a branch of a repository // see https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch func GetBranch(ctx *context.APIContext) { - branch, err := ctx.Repo.Repository.GetBranch(ctx.Params(":branchname")) + if ctx.Repo.TreePath != "" { + // if TreePath != "", then URL contained extra slashes + // (i.e. "master/subbranch" instead of "master"), so branch does + // not exist + ctx.Status(404) + return + } + branch, err := ctx.Repo.Repository.GetBranch(ctx.Repo.BranchName) if err != nil { if models.IsErrBranchNotExist(err) { ctx.Error(404, "GetBranch", err) |