aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/pull.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-03-28 04:13:18 +0000
committerGitHub <noreply@github.com>2020-03-28 01:13:18 -0300
commit7cd47046ea6e1fde2c88290a42f345795aee0ea4 (patch)
tree6004084e3c478a68a47b47deb0143a2b142fb821 /routers/repo/pull.go
parentcac30abefc02e36ed08810b7101b4f6a7c8bb599 (diff)
downloadgitea-7cd47046ea6e1fde2c88290a42f345795aee0ea4.tar.gz
gitea-7cd47046ea6e1fde2c88290a42f345795aee0ea4.zip
Handle push rejection in branch and upload (#10854)
* Handle push rejections and push out-of-date in branch creation and file upload. * Remove the duplicated sanitize from services/pull/merge * Move the errors Err(Merge)PushOutOfDate and ErrPushRejected to modules/git * Handle errors better in the upload file dialogs Fix #10460 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Diffstat (limited to 'routers/repo/pull.go')
-rw-r--r--routers/repo/pull.go18
1 files changed, 4 insertions, 14 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index e7cd672e3c..5fb5bfa2bb 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -10,7 +10,6 @@ import (
"container/list"
"crypto/subtle"
"fmt"
- "html"
"net/http"
"path"
"strings"
@@ -668,18 +667,9 @@ func UpdatePullRequest(ctx *context.Context) {
message := fmt.Sprintf("Merge branch '%s' into %s", issue.PullRequest.BaseBranch, issue.PullRequest.HeadBranch)
if err = pull_service.Update(issue.PullRequest, ctx.User, message); err != nil {
- sanitize := func(x string) string {
- runes := []rune(x)
-
- if len(runes) > 512 {
- x = "..." + string(runes[len(runes)-512:])
- }
-
- return strings.Replace(html.EscapeString(x), "\n", "<br>", -1)
- }
if models.IsErrMergeConflicts(err) {
conflictError := err.(models.ErrMergeConflicts)
- ctx.Flash.Error(ctx.Tr("repo.pulls.merge_conflict", sanitize(conflictError.StdErr), sanitize(conflictError.StdOut)))
+ ctx.Flash.Error(ctx.Tr("repo.pulls.merge_conflict", utils.SanitizeFlashErrorString(conflictError.StdErr), utils.SanitizeFlashErrorString(conflictError.StdOut)))
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
return
}
@@ -814,14 +804,14 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
ctx.Flash.Error(ctx.Tr("repo.pulls.unrelated_histories"))
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
return
- } else if models.IsErrMergePushOutOfDate(err) {
+ } else if git.IsErrPushOutOfDate(err) {
log.Debug("MergePushOutOfDate error: %v", err)
ctx.Flash.Error(ctx.Tr("repo.pulls.merge_out_of_date"))
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
return
- } else if models.IsErrPushRejected(err) {
+ } else if git.IsErrPushRejected(err) {
log.Debug("MergePushRejected error: %v", err)
- pushrejErr := err.(models.ErrPushRejected)
+ pushrejErr := err.(*git.ErrPushRejected)
message := pushrejErr.Message
if len(message) == 0 {
ctx.Flash.Error(ctx.Tr("repo.pulls.push_rejected_no_message"))