diff options
author | Brecht Van Lommel <brecht@blender.org> | 2023-01-29 22:00:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-29 15:00:10 -0600 |
commit | 3ff5a6a365ab32b6356292fa2266fa36bb08f293 (patch) | |
tree | 5f8f6b80357eb3c576c3fab4f211dada1364963d /routers/private | |
parent | d283a31f03eae2fc2bd8dc01b2c366308e81e50c (diff) | |
download | gitea-3ff5a6a365ab32b6356292fa2266fa36bb08f293.tar.gz gitea-3ff5a6a365ab32b6356292fa2266fa36bb08f293.zip |
Fix missing message in git hook when pull requests disabled on fork (#22625)
And also the other way around, it would show an non-working URL in the
message when pull requests are disabled on the base repository but
enabled on the fork.
Diffstat (limited to 'routers/private')
-rw-r--r-- | routers/private/hook_post_receive.go | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/routers/private/hook_post_receive.go b/routers/private/hook_post_receive.go index c62038899d..75de47bdc4 100644 --- a/routers/private/hook_post_receive.go +++ b/routers/private/hook_post_receive.go @@ -173,13 +173,6 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) { return } - if !repo.AllowsPulls() { - // We can stop there's no need to go any further - ctx.JSON(http.StatusOK, private.HookPostReceiveResult{ - RepoWasEmpty: wasEmpty, - }) - return - } baseRepo = repo if repo.IsFork { @@ -191,7 +184,17 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) { }) return } - baseRepo = repo.BaseRepo + if repo.BaseRepo.AllowsPulls() { + baseRepo = repo.BaseRepo + } + } + + if !baseRepo.AllowsPulls() { + // We can stop there's no need to go any further + ctx.JSON(http.StatusOK, private.HookPostReceiveResult{ + RepoWasEmpty: wasEmpty, + }) + return } } @@ -217,14 +220,14 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) { branch = fmt.Sprintf("%s:%s", repo.OwnerName, branch) } results = append(results, private.HookPostReceiveBranchResult{ - Message: setting.Git.PullRequestPushMessage && repo.AllowsPulls(), + Message: setting.Git.PullRequestPushMessage && baseRepo.AllowsPulls(), Create: true, Branch: branch, URL: fmt.Sprintf("%s/compare/%s...%s", baseRepo.HTMLURL(), util.PathEscapeSegments(baseRepo.DefaultBranch), util.PathEscapeSegments(branch)), }) } else { results = append(results, private.HookPostReceiveBranchResult{ - Message: setting.Git.PullRequestPushMessage && repo.AllowsPulls(), + Message: setting.Git.PullRequestPushMessage && baseRepo.AllowsPulls(), Create: false, Branch: branch, URL: fmt.Sprintf("%s/pulls/%d", baseRepo.HTMLURL(), pr.Index), |