From c7db4af34542e8c69135adfb2db2e6df67180237 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Thu, 8 Aug 2024 17:26:36 +0800 Subject: [PATCH] Add warning message in merge instructions when AutodetectManualMerge was not enabled quick-fix https://github.com/go-gitea/gitea/issues/31433 , maybe need more disscusion about better solutions. Signed-off-by: a1012112796 <1012112796@qq.com> --- options/locale/locale_en-US.ini | 1 + routers/web/repo/issue.go | 2 ++ .../repo/issue/view_content/pull_merge_instruction.tmpl | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 92f955c78a7e..9ba9a19f16ca 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1890,6 +1890,7 @@ pulls.cmd_instruction_checkout_title = Checkout pulls.cmd_instruction_checkout_desc = From your project repository, check out a new branch and test the changes. pulls.cmd_instruction_merge_title = Merge pulls.cmd_instruction_merge_desc = Merge the changes and update on Gitea. +pulls.cmd_instruction_merge_warning = Warning: This operation can not merge pull request because "autodetect manual merge" was not enable pulls.clear_merge_message = Clear merge message pulls.clear_merge_message_hint = Clearing the merge message will only remove the commit message content and keep generated git trailers such as "Co-Authored-By …". diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 1018e88f1bc3..9cf3269f18e9 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1864,6 +1864,8 @@ func ViewIssue(ctx *context.Context) { } prConfig := prUnit.PullRequestsConfig() + ctx.Data["AutodetectManualMerge"] = prConfig.AutodetectManualMerge + var mergeStyle repo_model.MergeStyle // Check correct values and select default if ms, ok := ctx.Data["MergeStyle"].(repo_model.MergeStyle); !ok || diff --git a/templates/repo/issue/view_content/pull_merge_instruction.tmpl b/templates/repo/issue/view_content/pull_merge_instruction.tmpl index bb59b497190b..9a3e2cb7d755 100644 --- a/templates/repo/issue/view_content/pull_merge_instruction.tmpl +++ b/templates/repo/issue/view_content/pull_merge_instruction.tmpl @@ -15,7 +15,13 @@
git checkout {{$localBranch}}
{{if .ShowMergeInstructions}} -

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}}
+
+

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}

+ {{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}} + {{if not .AutodetectManualMerge}} +
{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_warning"}}
+ {{end}} +
git checkout {{.PullRequest.BaseBranch}}