Skip to content

Commit bc86134

Browse files
saitholafriks
authored andcommitted
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 <mario.lubenka@googlemail.com> * Update routers/repo/pull.go Co-Authored-By: saitho <mario.lubenka@googlemail.com>
1 parent b1bb700 commit bc86134

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ pulls.tab_conversation = Conversation
944944
pulls.tab_commits = Commits
945945
pulls.tab_files = Files Changed
946946
pulls.reopen_to_merge = Please reopen this pull request to perform a merge.
947+
pulls.cant_reopen_deleted_branch = This pull request cannot be reopened because the branch was deleted.
947948
pulls.merged = Merged
948949
pulls.has_merged = The pull request has been merged.
949950
pulls.title_wip_desc = `<a href="#">Start the title with <strong>%s</strong></a> to prevent the pull request from being merged accidentally.`

routers/repo/issue.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ func ViewIssue(ctx *context.Context) {
674674
PrepareMergedViewPullInfo(ctx, issue)
675675
} else {
676676
PrepareViewPullInfo(ctx, issue)
677+
ctx.Data["DisableStatusChange"] = ctx.Data["IsPullRequestBroken"] == true && issue.IsClosed
677678
}
678679
if ctx.Written() {
679680
return

routers/repo/pull.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,8 @@ func CleanUpPullRequest(ctx *context.Context) {
999999

10001000
pr := issue.PullRequest
10011001

1002-
// Allow cleanup only for merged PR
1003-
if !pr.HasMerged {
1002+
// Don't cleanup unmerged and unclosed PRs
1003+
if !pr.HasMerged && !issue.IsClosed {
10041004
ctx.NotFound("CleanUpPullRequest", nil)
10051005
return
10061006
}

templates/repo/issue/view_content/pull.tmpl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,18 @@
5858
{{end}}
5959
{{else if .Issue.IsClosed}}
6060
<div class="item text grey">
61-
{{$.i18n.Tr "repo.pulls.reopen_to_merge"}}
61+
{{if .IsPullRequestBroken}}
62+
{{$.i18n.Tr "repo.pulls.cant_reopen_deleted_branch"}}
63+
{{else}}
64+
{{$.i18n.Tr "repo.pulls.reopen_to_merge"}}
65+
{{end}}
6266
</div>
67+
{{if .IsPullBranchDeletable}}
68+
<div class="ui divider"></div>
69+
<div>
70+
<a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</a>
71+
</div>
72+
{{end}}
6373
{{else if .IsPullFilesConflicted}}
6474
<div class="item text grey">
6575
<span class="octicon octicon-x"></span>

0 commit comments

Comments
 (0)