Skip to content

Show "delete branch" button on closed pull requests (#6570) #6601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<a href="#">Start the title with <strong>%s</strong></a> to prevent the pull request from being merged accidentally.`
Expand Down
1 change: 1 addition & 0 deletions routers/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions routers/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 11 additions & 1 deletion templates/repo/issue/view_content/pull.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,18 @@
{{end}}
{{else if .Issue.IsClosed}}
<div class="item text grey">
{{$.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}}
</div>
{{if .IsPullBranchDeletable}}
<div class="ui divider"></div>
<div>
<a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</a>
</div>
{{end}}
{{else if .IsPullFilesConflicted}}
<div class="item text grey">
<span class="octicon octicon-x"></span>
Expand Down