Skip to content

Commit cc42c64

Browse files
a10121127966543
andauthored
fix delete pull head ref for DeleteIssue (#20032)
* fix delete pull head ref for DeleteIssue fix #19655 Signed-off-by: a1012112796 <[email protected]> * add different help message for delete pull request Signed-off-by: a1012112796 <[email protected]> Co-authored-by: 6543 <[email protected]>
1 parent e86f18a commit cc42c64

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

options/locale/locale_en-US.ini

+3
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,9 @@ pulls.auto_merge_canceled_schedule = The auto merge was canceled for this pull r
16101610
pulls.auto_merge_newly_scheduled_comment = `scheduled this pull request to auto merge when all checks succeed %[1]s`
16111611
pulls.auto_merge_canceled_schedule_comment = `canceled auto merging this pull request when all checks succeed %[1]s`
16121612

1613+
pulls.delete.title = Delete this pull request?
1614+
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)
1615+
16131616
milestones.new = New Milestone
16141617
milestones.closed = Closed %s
16151618
milestones.update_ago = Updated %s ago

routers/web/repo/issue.go

+5
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,11 @@ func DeleteIssue(ctx *context.Context) {
878878
return
879879
}
880880

881+
if issue.IsPull {
882+
ctx.Redirect(fmt.Sprintf("%s/pulls", ctx.Repo.Repository.HTMLURL()), http.StatusSeeOther)
883+
return
884+
}
885+
881886
ctx.Redirect(fmt.Sprintf("%s/issues", ctx.Repo.Repository.HTMLURL()), http.StatusSeeOther)
882887
}
883888

services/issue/issue.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_m
149149

150150
// delete pull request related git data
151151
if issue.IsPull {
152-
if err := gitRepo.RemoveReference(fmt.Sprintf("%s%d", git.PullPrefix, issue.PullRequest.Index)); err != nil {
152+
if err := gitRepo.RemoveReference(fmt.Sprintf("%s%d/head", git.PullPrefix, issue.PullRequest.Index)); err != nil {
153153
return err
154154
}
155155
}

templates/repo/issue/view_content/sidebar.tmpl

+10-2
Original file line numberDiff line numberDiff line change
@@ -660,11 +660,19 @@
660660
</button>
661661
<div class="ui basic modal" id="delete">
662662
<div class="ui icon header">
663-
{{.i18n.Tr "repo.issues.delete.title"}}
663+
{{if .Issue.IsPull}}
664+
{{.i18n.Tr "repo.pulls.delete.title"}}
665+
{{else}}
666+
{{.i18n.Tr "repo.issues.delete.title"}}
667+
{{end}}
664668
</div>
665669
<div class="content center">
666670
<p>
667-
{{.i18n.Tr "repo.issues.delete.text"}}
671+
{{if .Issue.IsPull}}
672+
{{.i18n.Tr "repo.pulls.delete.text"}}
673+
{{else}}
674+
{{.i18n.Tr "repo.issues.delete.text"}}
675+
{{end}}
668676
</p>
669677
</div>
670678
<form action="{{.Issue.Link}}/delete" method="post">

0 commit comments

Comments
 (0)