1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-26 09:09:36 -05:00

Fix error display when merging PRs (#29288) (#29309)

Backport #29288
Partially fix #29071, regression of Modernize merge button #28140

Fix some missing `Redirect` -> `JSONRedirect`.

Thanks @yp05327 for the help in
https://github.com/go-gitea/gitea/issues/29071#issuecomment-1931261075

(cherry picked from commit dcb9c38568dc4e9502fc416de237cce0eac41cba)
This commit is contained in:
Zettat123 2024-02-22 10:32:54 +08:00 committed by Earl Warren
parent 47e70bbf0e
commit 9a63c6f39a
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -1236,19 +1236,19 @@ func MergePullRequest(ctx *context.Context) {
return return
} }
ctx.Flash.Error(flashError) ctx.Flash.Error(flashError)
ctx.Redirect(issue.Link()) ctx.JSONRedirect(issue.Link())
} else if models.IsErrMergeUnrelatedHistories(err) { } else if models.IsErrMergeUnrelatedHistories(err) {
log.Debug("MergeUnrelatedHistories error: %v", err) log.Debug("MergeUnrelatedHistories error: %v", err)
ctx.Flash.Error(ctx.Tr("repo.pulls.unrelated_histories")) ctx.Flash.Error(ctx.Tr("repo.pulls.unrelated_histories"))
ctx.Redirect(issue.Link()) ctx.JSONRedirect(issue.Link())
} else if git.IsErrPushOutOfDate(err) { } else if git.IsErrPushOutOfDate(err) {
log.Debug("MergePushOutOfDate error: %v", err) log.Debug("MergePushOutOfDate error: %v", err)
ctx.Flash.Error(ctx.Tr("repo.pulls.merge_out_of_date")) ctx.Flash.Error(ctx.Tr("repo.pulls.merge_out_of_date"))
ctx.Redirect(issue.Link()) ctx.JSONRedirect(issue.Link())
} else if models.IsErrSHADoesNotMatch(err) { } else if models.IsErrSHADoesNotMatch(err) {
log.Debug("MergeHeadOutOfDate error: %v", err) log.Debug("MergeHeadOutOfDate error: %v", err)
ctx.Flash.Error(ctx.Tr("repo.pulls.head_out_of_date")) ctx.Flash.Error(ctx.Tr("repo.pulls.head_out_of_date"))
ctx.Redirect(issue.Link()) ctx.JSONRedirect(issue.Link())
} else if git.IsErrPushRejected(err) { } else if git.IsErrPushRejected(err) {
log.Debug("MergePushRejected error: %v", err) log.Debug("MergePushRejected error: %v", err)
pushrejErr := err.(*git.ErrPushRejected) pushrejErr := err.(*git.ErrPushRejected)