From eb7753854ad95af9bb3ed89a4ddc70a121ef8059 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Sun, 19 Jun 2022 03:10:14 +0000 Subject: [PATCH 1/2] fix delete pull head ref for DeleteIssue fix #19655 Signed-off-by: a1012112796 <1012112796@qq.com> --- routers/web/repo/issue.go | 5 +++++ services/issue/issue.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 11d2daeeff0da..5b72ff79af370 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -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) } diff --git a/services/issue/issue.go b/services/issue/issue.go index ded281e209e2b..467bc14b84594 100644 --- a/services/issue/issue.go +++ b/services/issue/issue.go @@ -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 } } From eda99e7b651a057ece63c9dc5ee48333ce3a9564 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Sun, 19 Jun 2022 03:34:25 +0000 Subject: [PATCH 2/2] add different help message for delete pull request Signed-off-by: a1012112796 <1012112796@qq.com> --- options/locale/locale_en-US.ini | 3 +++ templates/repo/issue/view_content/sidebar.tmpl | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 347022fbdb39b..72253b3640866 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -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 diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 7a966ce8788f4..d58e6e7b9ff4d 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -660,11 +660,19 @@