|
|
@ -26,6 +26,7 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/repofiles" |
|
|
|
"code.gitea.io/gitea/modules/repofiles" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"code.gitea.io/gitea/modules/util" |
|
|
|
"code.gitea.io/gitea/modules/util" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/routers/utils" |
|
|
|
"code.gitea.io/gitea/services/gitdiff" |
|
|
|
"code.gitea.io/gitea/services/gitdiff" |
|
|
|
pull_service "code.gitea.io/gitea/services/pull" |
|
|
|
pull_service "code.gitea.io/gitea/services/pull" |
|
|
|
repo_service "code.gitea.io/gitea/services/repository" |
|
|
|
repo_service "code.gitea.io/gitea/services/repository" |
|
|
@ -774,27 +775,18 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err = pull_service.Merge(pr, ctx.User, ctx.Repo.GitRepo, models.MergeStyle(form.Do), message); err != nil { |
|
|
|
if err = pull_service.Merge(pr, ctx.User, ctx.Repo.GitRepo, models.MergeStyle(form.Do), 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.IsErrInvalidMergeStyle(err) { |
|
|
|
if models.IsErrInvalidMergeStyle(err) { |
|
|
|
ctx.Flash.Error(ctx.Tr("repo.pulls.invalid_merge_option")) |
|
|
|
ctx.Flash.Error(ctx.Tr("repo.pulls.invalid_merge_option")) |
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) |
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) |
|
|
|
return |
|
|
|
return |
|
|
|
} else if models.IsErrMergeConflicts(err) { |
|
|
|
} else if models.IsErrMergeConflicts(err) { |
|
|
|
conflictError := err.(models.ErrMergeConflicts) |
|
|
|
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(pr.Index)) |
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) |
|
|
|
return |
|
|
|
return |
|
|
|
} else if models.IsErrRebaseConflicts(err) { |
|
|
|
} else if models.IsErrRebaseConflicts(err) { |
|
|
|
conflictError := err.(models.ErrRebaseConflicts) |
|
|
|
conflictError := err.(models.ErrRebaseConflicts) |
|
|
|
ctx.Flash.Error(ctx.Tr("repo.pulls.rebase_conflict", sanitize(conflictError.CommitSHA), sanitize(conflictError.StdErr), sanitize(conflictError.StdOut))) |
|
|
|
ctx.Flash.Error(ctx.Tr("repo.pulls.rebase_conflict", utils.SanitizeFlashErrorString(conflictError.CommitSHA), utils.SanitizeFlashErrorString(conflictError.StdErr), utils.SanitizeFlashErrorString(conflictError.StdOut))) |
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) |
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) |
|
|
|
return |
|
|
|
return |
|
|
|
} else if models.IsErrMergeUnrelatedHistories(err) { |
|
|
|
} else if models.IsErrMergeUnrelatedHistories(err) { |
|
|
@ -807,6 +799,17 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { |
|
|
|
ctx.Flash.Error(ctx.Tr("repo.pulls.merge_out_of_date")) |
|
|
|
ctx.Flash.Error(ctx.Tr("repo.pulls.merge_out_of_date")) |
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) |
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
} else if models.IsErrPushRejected(err) { |
|
|
|
|
|
|
|
log.Debug("MergePushRejected error: %v", err) |
|
|
|
|
|
|
|
pushrejErr := err.(models.ErrPushRejected) |
|
|
|
|
|
|
|
message := pushrejErr.Message |
|
|
|
|
|
|
|
if len(message) == 0 { |
|
|
|
|
|
|
|
ctx.Flash.Error(ctx.Tr("repo.pulls.push_rejected_no_message")) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ctx.Flash.Error(ctx.Tr("repo.pulls.push_rejected", utils.SanitizeFlashErrorString(pushrejErr.Message))) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.ServerError("Merge", err) |
|
|
|
ctx.ServerError("Merge", err) |
|
|
|
return |
|
|
|
return |
|
|
|