mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-28 06:33:50 +03:00
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.
This commit is contained in:
parent
d283a31f03
commit
3ff5a6a365
1 changed files with 13 additions and 10 deletions
|
@ -173,13 +173,6 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||||
return
|
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
|
baseRepo = repo
|
||||||
|
|
||||||
if repo.IsFork {
|
if repo.IsFork {
|
||||||
|
@ -191,7 +184,17 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||||
})
|
})
|
||||||
return
|
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)
|
branch = fmt.Sprintf("%s:%s", repo.OwnerName, branch)
|
||||||
}
|
}
|
||||||
results = append(results, private.HookPostReceiveBranchResult{
|
results = append(results, private.HookPostReceiveBranchResult{
|
||||||
Message: setting.Git.PullRequestPushMessage && repo.AllowsPulls(),
|
Message: setting.Git.PullRequestPushMessage && baseRepo.AllowsPulls(),
|
||||||
Create: true,
|
Create: true,
|
||||||
Branch: branch,
|
Branch: branch,
|
||||||
URL: fmt.Sprintf("%s/compare/%s...%s", baseRepo.HTMLURL(), util.PathEscapeSegments(baseRepo.DefaultBranch), util.PathEscapeSegments(branch)),
|
URL: fmt.Sprintf("%s/compare/%s...%s", baseRepo.HTMLURL(), util.PathEscapeSegments(baseRepo.DefaultBranch), util.PathEscapeSegments(branch)),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
results = append(results, private.HookPostReceiveBranchResult{
|
results = append(results, private.HookPostReceiveBranchResult{
|
||||||
Message: setting.Git.PullRequestPushMessage && repo.AllowsPulls(),
|
Message: setting.Git.PullRequestPushMessage && baseRepo.AllowsPulls(),
|
||||||
Create: false,
|
Create: false,
|
||||||
Branch: branch,
|
Branch: branch,
|
||||||
URL: fmt.Sprintf("%s/pulls/%d", baseRepo.HTMLURL(), pr.Index),
|
URL: fmt.Sprintf("%s/pulls/%d", baseRepo.HTMLURL(), pr.Index),
|
||||||
|
|
Loading…
Reference in a new issue