From dcaa5643d70cd1be72e53e82a30d2bc6e5f8de92 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 21 Mar 2020 11:41:33 +0800 Subject: Fix branch api canPush and canMerge (#10776) Co-authored-by: techknowlogick --- routers/api/v1/repo/branch.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'routers/api') diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index fccfc2bfe1..0d4501cd79 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -72,7 +72,13 @@ func GetBranch(ctx *context.APIContext) { return } - ctx.JSON(http.StatusOK, convert.ToBranch(ctx.Repo.Repository, branch, c, branchProtection, ctx.User, ctx.Repo.IsAdmin())) + br, err := convert.ToBranch(ctx.Repo.Repository, branch, c, branchProtection, ctx.User, ctx.Repo.IsAdmin()) + if err != nil { + ctx.Error(http.StatusInternalServerError, "convert.ToBranch", err) + return + } + + ctx.JSON(http.StatusOK, br) } // ListBranches list all the branches of a repository @@ -115,7 +121,11 @@ func ListBranches(ctx *context.APIContext) { ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err) return } - apiBranches[i] = convert.ToBranch(ctx.Repo.Repository, branches[i], c, branchProtection, ctx.User, ctx.Repo.IsAdmin()) + apiBranches[i], err = convert.ToBranch(ctx.Repo.Repository, branches[i], c, branchProtection, ctx.User, ctx.Repo.IsAdmin()) + if err != nil { + ctx.Error(http.StatusInternalServerError, "convert.ToBranch", err) + return + } } ctx.JSON(http.StatusOK, &apiBranches) -- cgit v1.2.3