diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index 6f3141885b..47fcac7ae7 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -1306,7 +1306,7 @@ "repo.editor.upload_file_is_locked": "File \"%s\" is locked by %s.", "repo.editor.upload_files_to_dir": "Upload files to \"%s\"", "repo.editor.cannot_commit_to_protected_branch": "Cannot commit to protected branch \"%s\".", - "repo.editor.no_commit_to_branch": "Unable to commit directly to branch because:", + "repo.editor.no_commit_to_branch": "Not allowed to commit directly to branch because:", "repo.editor.user_no_push_to_branch": "User cannot push to branch", "repo.editor.require_signed_commit": "Branch requires a signed commit", "repo.editor.cherry_pick": "Cherry-pick %s onto:", diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index eab4df77ad..d20bbdc36c 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -974,17 +974,15 @@ func UpdatePullRequest(ctx *context.Context) { return } - // ToDo: add check if maintainers are allowed to change branch ... (need migration & co) if (!allowedUpdateByMerge && !rebase) || (rebase && !allowedUpdateByRebase) { - ctx.Flash.Error(ctx.Tr("repo.pulls.update_not_allowed")) - ctx.Redirect(issue.Link()) + ctx.JSONError(ctx.Tr("repo.pulls.update_not_allowed")) return } // default merge commit message message := fmt.Sprintf("Merge branch '%s' into %s", issue.PullRequest.BaseBranch, issue.PullRequest.HeadBranch) - // The update process should not be cancelled by the user + // The update process should not be canceled by the user // so we set the context to be a background context if err = pull_service.Update(graceful.GetManager().ShutdownContext(), issue.PullRequest, ctx.Doer, message, rebase); err != nil { if pull_service.IsErrMergeConflicts(err) { @@ -998,8 +996,7 @@ func UpdatePullRequest(ctx *context.Context) { ctx.ServerError("UpdatePullRequest.HTMLString", err) return } - ctx.Flash.Error(flashError) - ctx.Redirect(issue.Link()) + ctx.JSONError(flashError) return } else if pull_service.IsErrRebaseConflicts(err) { conflictError := err.(pull_service.ErrRebaseConflicts) @@ -1012,19 +1009,18 @@ func UpdatePullRequest(ctx *context.Context) { ctx.ServerError("UpdatePullRequest.HTMLString", err) return } - ctx.Flash.Error(flashError) - ctx.Redirect(issue.Link()) + ctx.JSONError(flashError) return } - ctx.Flash.Error(err.Error()) - ctx.Redirect(issue.Link()) + log.Error("Update pull request failed: %v", err) + ctx.JSONError("Unable to update pull request") return } - time.Sleep(1 * time.Second) + time.Sleep(100 * time.Millisecond) // TODO: it is really questionable whether the Sleep is useful here, need to figure out ctx.Flash.Success(ctx.Tr("repo.pulls.update_branch_success")) - ctx.Redirect(issue.Link()) + ctx.JSONRedirect(issue.Link()) } // MergePullRequest response for merging pull request diff --git a/templates/repo/editor/commit_form.tmpl b/templates/repo/editor/commit_form.tmpl index 7fdd36b3bd..d0c47e9bdd 100644 --- a/templates/repo/editor/commit_form.tmpl +++ b/templates/repo/editor/commit_form.tmpl @@ -22,7 +22,7 @@ -
{{ctx.Locale.Tr "repo.pulls.cmd_instruction_hint"}}
-{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_title"}}
{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_desc"}}{{/* align with other item icon & text */}} + {{ctx.Locale.Tr "repo.pulls.cmd_instruction_hint"}} +
+{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_title"}}
+ {{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_desc"}} +{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}
+{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}
{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}} {{if not $data.AutodetectManualMerge}}