Skip to content

Commit eb0330a

Browse files
authored
Ensure that rebase conflicts are handled in updates (#16952)
PR #16125 did not update the error handlers to handle conflict errors relating to rebases. This PR adds them. Fix #16922 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 4c7a70b commit eb0330a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

routers/api/v1/repo/pull.go

+3
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,9 @@ func UpdatePullRequest(ctx *context.APIContext) {
11361136
if models.IsErrMergeConflicts(err) {
11371137
ctx.Error(http.StatusConflict, "Update", "merge failed because of conflict")
11381138
return
1139+
} else if models.IsErrRebaseConflicts(err) {
1140+
ctx.Error(http.StatusConflict, "Update", "rebase failed because of conflict")
1141+
return
11391142
}
11401143
ctx.Error(http.StatusInternalServerError, "pull_service.Update", err)
11411144
return

routers/web/repo/pull.go

+15
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,21 @@ func UpdatePullRequest(ctx *context.Context) {
766766
ctx.Flash.Error(flashError)
767767
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))
768768
return
769+
} else if models.IsErrRebaseConflicts(err) {
770+
conflictError := err.(models.ErrRebaseConflicts)
771+
flashError, err := ctx.HTMLString(string(tplAlertDetails), map[string]interface{}{
772+
"Message": ctx.Tr("repo.pulls.rebase_conflict", utils.SanitizeFlashErrorString(conflictError.CommitSHA)),
773+
"Summary": ctx.Tr("repo.pulls.rebase_conflict_summary"),
774+
"Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut),
775+
})
776+
if err != nil {
777+
ctx.ServerError("UpdatePullRequest.HTMLString", err)
778+
return
779+
}
780+
ctx.Flash.Error(flashError)
781+
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))
782+
return
783+
769784
}
770785
ctx.Flash.Error(err.Error())
771786
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))

0 commit comments

Comments
 (0)