From 0cf030f407310bb5f8e28011ff2901e5d185b51a Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Sun, 17 Oct 2021 18:58:36 +0200 Subject: [PATCH] Hide command line merge instructions when user can't push (#17339) Hides the command line instructions if the authenticated user can't push to the base branch. Closes #17121 --- routers/web/repo/issue.go | 2 ++ templates/repo/issue/view_content/pull.tmpl | 38 +++++++++++---------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 1aaa27c2b00e3..173cb49e45127 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1543,6 +1543,7 @@ func ViewIssue(ctx *context.Context) { ctx.ServerError("LoadProtectedBranch", err) return } + ctx.Data["ShowMergeInstructions"] = true if pull.ProtectedBranch != nil { cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull) ctx.Data["IsBlockedByApprovals"] = !pull.ProtectedBranch.HasEnoughApprovals(pull) @@ -1554,6 +1555,7 @@ func ViewIssue(ctx *context.Context) { ctx.Data["ChangedProtectedFiles"] = pull.ChangedProtectedFiles ctx.Data["IsBlockedByChangedProtectedFiles"] = len(pull.ChangedProtectedFiles) != 0 ctx.Data["ChangedProtectedFilesNum"] = len(pull.ChangedProtectedFiles) + ctx.Data["ShowMergeInstructions"] = pull.ProtectedBranch.CanUserPush(ctx.User.ID) } ctx.Data["WillSign"] = false if ctx.User != nil { diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index aa0f3dc91aa6a..706cc0eac754a 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -485,25 +485,27 @@ {{end}} -
{{$.i18n.Tr "repo.pulls.merge_instruction_hint" | Safe}}
-