Skip to content

Commit a617294

Browse files
committed
Ensure that rebase conflicts are handled in updates
PR go-gitea#16125 did not update the error handlers to handle conflict errors relating to rebases. This PR adds them. Fix go-gitea#16922 Signed-off-by: Andrew Thornton <art27@cantab.net>
1 parent 7d1d32a commit a617294

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

routers/api/v1/repo/pull.go

+2
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,8 @@ 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")
11391141
}
11401142
ctx.Error(http.StatusInternalServerError, "pull_service.Update", err)
11411143
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)