From 30d4010983c372d05d3e53c23fe5539022835548 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 9 Oct 2024 18:34:08 -0700 Subject: [PATCH] Some improvements --- routers/web/repo/issue_dev.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/routers/web/repo/issue_dev.go b/routers/web/repo/issue_dev.go index 424f4946deb..4a8de2865f4 100644 --- a/routers/web/repo/issue_dev.go +++ b/routers/web/repo/issue_dev.go @@ -4,6 +4,8 @@ package repo import ( + "net/http" + git_model "code.gitea.io/gitea/models/git" issues_model "code.gitea.io/gitea/models/issues" access_model "code.gitea.io/gitea/models/perm/access" @@ -19,6 +21,11 @@ import ( ) func CreateBranchFromIssue(ctx *context.Context) { + if ctx.HasError() { // form binding error check + ctx.JSONError(ctx.GetErrMsg()) + return + } + issue := GetActionIssue(ctx) if ctx.Written() { return @@ -56,12 +63,7 @@ func CreateBranchFromIssue(ctx *context.Context) { canCreateBranch := perm.CanWrite(unit_model.TypeCode) && repo.CanCreateBranch() if !canCreateBranch { - ctx.NotFound("CreateBranch", nil) - return - } - - if ctx.HasError() { - ctx.JSONError(ctx.GetErrMsg()) + ctx.Error(http.StatusForbidden, "No permission to create branch in this repository") return }