Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 in prompting user to create one
hookPrintResult(res.ShouldShowMessage, false, res.HeadBranch, res.URL)
}
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
11 changes: 11 additions & 0 deletions routers/private/hook_proc_receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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: string(ctx.Tr("repo.pulls.new.must_collaborator")),
})
} else if errors.Is(err, user_model.ErrBlockedUser) {
ctx.JSON(http.StatusUnauthorized, private.Response{
Err: err.Error(), UserMsg: string(ctx.Tr("repo.pulls.new.blocked_user")),
})
} else {
log.Error(err.Error())
ctx.JSON(http.StatusInternalServerError, private.Response{
Expand Down
Loading