diff --git a/cmd/hook.go b/cmd/hook.go index 578380ab40db6..616f2393aa346 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -705,7 +705,8 @@ Gitea or set your environment appropriately.`, "") if err == nil { for _, res := range resp.Results { - hookPrintResult(res.ShouldShowMessage, res.IsCreatePR, res.HeadBranch, res.URL) + // AGit always creates a pull request so there is no point is prompting user to create one + hookPrintResult(res.ShouldShowMessage, false, res.HeadBranch, res.URL) } } diff --git a/cmd/serv.go b/cmd/serv.go index d2271b68d29e5..39b351fbcc462 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -104,7 +104,9 @@ func fail(ctx context.Context, userMessage, logMsgFmt string, args ...any) error // There appears to be a chance to cause a zombie process and failure to read the Exit status // if nothing is outputted on stdout. _, _ = fmt.Fprintln(os.Stdout, "") - _, _ = fmt.Fprintln(os.Stderr, "Gitea:", userMessage) + _, _ = fmt.Fprintln(os.Stderr, "error:") + _, _ = fmt.Fprintln(os.Stderr, "error:", userMessage) + _, _ = fmt.Fprintln(os.Stderr, "error:") if logMsgFmt != "" { logMsg := fmt.Sprintf(logMsgFmt, args...) diff --git a/routers/private/hook_proc_receive.go b/routers/private/hook_proc_receive.go index efb3f5831e427..991a2dd7da8e1 100644 --- a/routers/private/hook_proc_receive.go +++ b/routers/private/hook_proc_receive.go @@ -4,9 +4,12 @@ package private import ( + "errors" "net/http" + issues_model "code.gitea.io/gitea/models/issues" repo_model "code.gitea.io/gitea/models/repo" + user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/private" @@ -27,6 +30,14 @@ func HookProcReceive(ctx *gitea_context.PrivateContext) { if err != nil { if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) { ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error()) + } else if errors.Is(err, issues_model.ErrMustCollaborator) { + ctx.JSON(http.StatusUnauthorized, private.Response{ + Err: err.Error(), UserMsg: "You must be a collaborator to submit a pull request", + }) + } else if errors.Is(err, user_model.ErrBlockedUser) { + ctx.JSON(http.StatusUnauthorized, private.Response{ + Err: err.Error(), UserMsg: "You have been blocked by repository owner", + }) } else { log.Error(err.Error()) ctx.JSON(http.StatusInternalServerError, private.Response{ diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 9f3d1c1b7c032..0e4840fae30bf 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -1356,6 +1356,7 @@ func CompareAndPullRequestPost(ctx *context.Context) { flashError, err := ctx.RenderToHTML(tplAlertDetails, map[string]any{ "Message": ctx.Tr("repo.pulls.push_rejected"), "Summary": ctx.Tr("repo.pulls.new.blocked_user"), + "Details": "", }) if err != nil { ctx.ServerError("CompareAndPullRequest.HTMLString", err) @@ -1366,6 +1367,7 @@ func CompareAndPullRequestPost(ctx *context.Context) { flashError, err := ctx.RenderToHTML(tplAlertDetails, map[string]any{ "Message": ctx.Tr("repo.pulls.push_rejected"), "Summary": ctx.Tr("repo.pulls.new.must_collaborator"), + "Details": "", }) if err != nil { ctx.ServerError("CompareAndPullRequest.HTMLString", err)