From bc861347597a88ed476ec0124c4c4baf773255c3 Mon Sep 17 00:00:00 2001 From: Mario Lubenka Date: Sat, 20 Apr 2019 22:50:34 +0200 Subject: [PATCH] Show "delete branch" button on closed pull requests (#6570) (#6601) * Show button to delete a pull request branch after a pull request has been closed (#6570) Signed-off-by: Mario Lubenka * Update routers/repo/pull.go Co-Authored-By: saitho --- options/locale/locale_en-US.ini | 1 + routers/repo/issue.go | 1 + routers/repo/pull.go | 4 ++-- templates/repo/issue/view_content/pull.tmpl | 12 +++++++++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index bcdd252b66..eedede2a05 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -944,6 +944,7 @@ pulls.tab_conversation = Conversation pulls.tab_commits = Commits pulls.tab_files = Files Changed pulls.reopen_to_merge = Please reopen this pull request to perform a merge. +pulls.cant_reopen_deleted_branch = This pull request cannot be reopened because the branch was deleted. pulls.merged = Merged pulls.has_merged = The pull request has been merged. pulls.title_wip_desc = `Start the title with %s to prevent the pull request from being merged accidentally.` diff --git a/routers/repo/issue.go b/routers/repo/issue.go index c818ac4840..7a681033af 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -674,6 +674,7 @@ func ViewIssue(ctx *context.Context) { PrepareMergedViewPullInfo(ctx, issue) } else { PrepareViewPullInfo(ctx, issue) + ctx.Data["DisableStatusChange"] = ctx.Data["IsPullRequestBroken"] == true && issue.IsClosed } if ctx.Written() { return diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 14ab2207b5..0616ee2c77 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -999,8 +999,8 @@ func CleanUpPullRequest(ctx *context.Context) { pr := issue.PullRequest - // Allow cleanup only for merged PR - if !pr.HasMerged { + // Don't cleanup unmerged and unclosed PRs + if !pr.HasMerged && !issue.IsClosed { ctx.NotFound("CleanUpPullRequest", nil) return } diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 0ddb2820fc..73c4179080 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -58,8 +58,18 @@ {{end}} {{else if .Issue.IsClosed}}
- {{$.i18n.Tr "repo.pulls.reopen_to_merge"}} + {{if .IsPullRequestBroken}} + {{$.i18n.Tr "repo.pulls.cant_reopen_deleted_branch"}} + {{else}} + {{$.i18n.Tr "repo.pulls.reopen_to_merge"}} + {{end}}
+ {{if .IsPullBranchDeletable}} +
+
+ {{$.i18n.Tr "repo.branch.delete" .HeadTarget}} +
+ {{end}} {{else if .IsPullFilesConflicted}}