mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	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 <art27@cantab.net>
This commit is contained in:
		@@ -1136,6 +1136,9 @@ func UpdatePullRequest(ctx *context.APIContext) {
 | 
				
			|||||||
		if models.IsErrMergeConflicts(err) {
 | 
							if models.IsErrMergeConflicts(err) {
 | 
				
			||||||
			ctx.Error(http.StatusConflict, "Update", "merge failed because of conflict")
 | 
								ctx.Error(http.StatusConflict, "Update", "merge failed because of conflict")
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
 | 
							} else if models.IsErrRebaseConflicts(err) {
 | 
				
			||||||
 | 
								ctx.Error(http.StatusConflict, "Update", "rebase failed because of conflict")
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		ctx.Error(http.StatusInternalServerError, "pull_service.Update", err)
 | 
							ctx.Error(http.StatusInternalServerError, "pull_service.Update", err)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -766,6 +766,21 @@ func UpdatePullRequest(ctx *context.Context) {
 | 
				
			|||||||
			ctx.Flash.Error(flashError)
 | 
								ctx.Flash.Error(flashError)
 | 
				
			||||||
			ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))
 | 
								ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
 | 
							} else if models.IsErrRebaseConflicts(err) {
 | 
				
			||||||
 | 
								conflictError := err.(models.ErrRebaseConflicts)
 | 
				
			||||||
 | 
								flashError, err := ctx.HTMLString(string(tplAlertDetails), map[string]interface{}{
 | 
				
			||||||
 | 
									"Message": ctx.Tr("repo.pulls.rebase_conflict", utils.SanitizeFlashErrorString(conflictError.CommitSHA)),
 | 
				
			||||||
 | 
									"Summary": ctx.Tr("repo.pulls.rebase_conflict_summary"),
 | 
				
			||||||
 | 
									"Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut),
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									ctx.ServerError("UpdatePullRequest.HTMLString", err)
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								ctx.Flash.Error(flashError)
 | 
				
			||||||
 | 
								ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		ctx.Flash.Error(err.Error())
 | 
							ctx.Flash.Error(err.Error())
 | 
				
			||||||
		ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))
 | 
							ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user