diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index bb814eab6e..cd20c0b18e 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -348,6 +348,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
}
if !baseGitRepo.IsBranchExist(pull.BaseBranch) {
+ ctx.Data["BaseBranchNotExist"] = true
ctx.Data["IsPullRequestBroken"] = true
ctx.Data["BaseTarget"] = pull.BaseBranch
ctx.Data["HeadTarget"] = pull.HeadBranch
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl
index 477b6b33c6..47551c86e4 100644
--- a/templates/repo/issue/view_content/comments.tmpl
+++ b/templates/repo/issue/view_content/comments.tmpl
@@ -231,7 +231,8 @@
{{template "shared/user/avatarlink" dict "user" .Poster}}
{{template "shared/user/authorlink" .Poster}}
- {{ctx.Locale.Tr "repo.issues.delete_branch_at" .OldRef $createdStr}}
+ {{$oldRef := HTMLFormat `%s` .OldRef}}
+ {{ctx.Locale.Tr "repo.issues.delete_branch_at" $oldRef $createdStr}}
{{else if eq .Type 12}}
diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl
index 26b36d6ffc..cf775f22b5 100644
--- a/templates/repo/issue/view_title.tmpl
+++ b/templates/repo/issue/view_title.tmpl
@@ -61,12 +61,16 @@
{{if .Issue.PullRequest.IsAgitFlow}}
{{$headHref = HTMLFormat `%s AGit` $headHref "https://docs.gitea.com/usage/agit" (ctx.Locale.Tr "repo.pull.agit_documentation")}}
{{else}}
- {{$headHref = HTMLFormat `%s` (ctx.Locale.Tr "form.target_branch_not_exist") $headHref}}
+ {{$headHref = HTMLFormat `%s` (ctx.Locale.Tr "form.target_branch_not_exist") $headHref}}
{{end}}
{{end}}
{{$baseHref := .BaseTarget}}
{{if .BaseBranchLink}}
- {{$baseHref = HTMLFormat `%s` .BaseBranchLink $baseHref}}
+ {{if .BaseBranchNotExist}}
+ {{$baseHref = HTMLFormat `%s` (ctx.Locale.Tr "form.target_branch_not_exist") $baseHref}}
+ {{else}}
+ {{$baseHref = HTMLFormat `%s` .BaseBranchLink $baseHref}}
+ {{end}}
{{end}}
{{if .Issue.PullRequest.HasMerged}}
{{$mergedStr:= DateUtils.TimeSince .Issue.PullRequest.MergedUnix}}
diff --git a/tests/integration/pull_merge_test.go b/tests/integration/pull_merge_test.go
index 2351e169bc..bbd99f7aab 100644
--- a/tests/integration/pull_merge_test.go
+++ b/tests/integration/pull_merge_test.go
@@ -589,7 +589,8 @@ func TestPullDontRetargetChildOnWrongRepo(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
- targetBranch := htmlDoc.doc.Find("#branch_target>a").Text()
+ // the branch has been deleted, so there is no a html tag instead of span
+ targetBranch := htmlDoc.doc.Find("#branch_target>span").Text()
prStatus := strings.TrimSpace(htmlDoc.doc.Find(".issue-title-meta>.issue-state-label").Text())
assert.EqualValues(t, "base-pr", targetBranch)