Skip to content

Commit bb4e4fd

Browse files
committed
Ensure that rebase conflicts are handled in updates (go-gitea#16952)
Backport go-gitea#16952 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 67ceb61 commit bb4e4fd

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
@@ -1130,6 +1130,9 @@ func UpdatePullRequest(ctx *context.APIContext) {
11301130
if models.IsErrMergeConflicts(err) {
11311131
ctx.Error(http.StatusConflict, "Update", "merge failed because of conflict")
11321132
return
1133+
} else if models.IsErrRebaseConflicts(err) {
1134+
ctx.Error(http.StatusConflict, "Update", "rebase failed because of conflict")
1135+
return
11331136
}
11341137
ctx.Error(http.StatusInternalServerError, "pull_service.Update", err)
11351138
return

routers/web/repo/pull.go

+15
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,21 @@ func UpdatePullRequest(ctx *context.Context) {
752752
ctx.Flash.Error(flashError)
753753
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))
754754
return
755+
} else if models.IsErrRebaseConflicts(err) {
756+
conflictError := err.(models.ErrRebaseConflicts)
757+
flashError, err := ctx.HTMLString(string(tplAlertDetails), map[string]interface{}{
758+
"Message": ctx.Tr("repo.pulls.rebase_conflict", utils.SanitizeFlashErrorString(conflictError.CommitSHA)),
759+
"Summary": ctx.Tr("repo.pulls.rebase_conflict_summary"),
760+
"Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut),
761+
})
762+
if err != nil {
763+
ctx.ServerError("UpdatePullRequest.HTMLString", err)
764+
return
765+
}
766+
ctx.Flash.Error(flashError)
767+
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))
768+
return
769+
755770
}
756771
ctx.Flash.Error(err.Error())
757772
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))

0 commit comments

Comments
 (0)