Skip to content
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

Fix delete pull head ref for DeleteIssue #20032

Merged
merged 3 commits into from
Jun 19, 2022
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
3 changes: 3 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,9 @@ pulls.auto_merge_canceled_schedule = The auto merge was canceled for this pull r
pulls.auto_merge_newly_scheduled_comment = `scheduled this pull request to auto merge when all checks succeed %[1]s`
pulls.auto_merge_canceled_schedule_comment = `canceled auto merging this pull request when all checks succeed %[1]s`

pulls.delete.title = Delete this pull request?
pulls.delete.text = Do you really want to delete this pull request? (This will permanently remove all content. Consider closing it instead, if you intend to keep it archived)

milestones.new = New Milestone
milestones.closed = Closed %s
milestones.update_ago = Updated %s ago
Expand Down
5 changes: 5 additions & 0 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,11 @@ func DeleteIssue(ctx *context.Context) {
return
}

if issue.IsPull {
ctx.Redirect(fmt.Sprintf("%s/pulls", ctx.Repo.Repository.HTMLURL()), http.StatusSeeOther)
return
}

ctx.Redirect(fmt.Sprintf("%s/issues", ctx.Repo.Repository.HTMLURL()), http.StatusSeeOther)
}

Expand Down
2 changes: 1 addition & 1 deletion services/issue/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_m

// delete pull request related git data
if issue.IsPull {
if err := gitRepo.RemoveReference(fmt.Sprintf("%s%d", git.PullPrefix, issue.PullRequest.Index)); err != nil {
if err := gitRepo.RemoveReference(fmt.Sprintf("%s%d/head", git.PullPrefix, issue.PullRequest.Index)); err != nil {
return err
}
}
Expand Down
12 changes: 10 additions & 2 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,19 @@
</button>
<div class="ui basic modal" id="delete">
<div class="ui icon header">
{{.i18n.Tr "repo.issues.delete.title"}}
{{if .Issue.IsPull}}
{{.i18n.Tr "repo.pulls.delete.title"}}
{{else}}
{{.i18n.Tr "repo.issues.delete.title"}}
{{end}}
</div>
<div class="content center">
<p>
{{.i18n.Tr "repo.issues.delete.text"}}
{{if .Issue.IsPull}}
{{.i18n.Tr "repo.pulls.delete.text"}}
{{else}}
{{.i18n.Tr "repo.issues.delete.text"}}
{{end}}
</p>
</div>
<form action="{{.Issue.Link}}/delete" method="post">
Expand Down