From 1fe345bed27f0328d3e8d796c09fe8375d8d7cd4 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 5 Dec 2021 16:29:53 +0800 Subject: [PATCH 1/2] Improve interface when comparing a branch which has created a pull request --- options/locale/locale_en-US.ini | 1 + routers/web/repo/compare.go | 4 ++++ templates/repo/diff/compare.tmpl | 17 +++++++++++++++-- web_src/less/_repository.less | 9 +++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 3b0092a5ef35..44ee9b1fceba 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1429,6 +1429,7 @@ compare.compare_head = compare pulls.desc = Enable pull requests and code reviews. pulls.new = New Pull Request +pulls.view = View Pull Request pulls.compare_changes = New Pull Request pulls.compare_changes_desc = Select the branch to merge into and the branch to pull from. pulls.compare_base = merge into diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index c540cbc08ae5..3b016b15fbd6 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -735,6 +735,10 @@ func CompareDiff(ctx *context.Context) { } } else { ctx.Data["HasPullRequest"] = true + if err := pr.LoadIssue(); err != nil { + ctx.ServerError("LoadIssue", err) + return + } ctx.Data["PullRequest"] = pr ctx.HTML(http.StatusOK, tplCompareDiff) return diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl index 51198f4ebfd8..0c2fc2c32741 100644 --- a/templates/repo/diff/compare.tmpl +++ b/templates/repo/diff/compare.tmpl @@ -187,8 +187,21 @@ {{end}} {{else if and .PageIsComparePull (gt .CommitCount 0)}} {{if .HasPullRequest}} -
- {{.i18n.Tr "repo.pulls.has_pull_request" (Escape $.RepoLink) (Escape $.RepoRelPath) .PullRequest.Index | Safe}} +
+
+

+ {{RenderIssueTitle .PullRequest.Issue.Title $.RepoLink $.Repository.ComposeMetas}} + #{{.PullRequest.Issue.Index}} +

+
+
{{else}} {{if and $.IsSigned (not .Repository.IsArchived)}} diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less index bb4bee2805a9..7320f3e30251 100644 --- a/web_src/less/_repository.less +++ b/web_src/less/_repository.less @@ -1298,6 +1298,15 @@ .markup { font-size: 14px; } + + .title { + .issue-title { + margin-bottom: .5rem; + .index { + color: var(--color-text-light-2); + } + } + } } .filter.dropdown .menu { From 88c734269ec2c4b60b265edc11dfa6f56df041ca Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 22 Dec 2021 13:34:59 +0800 Subject: [PATCH 2/2] Take the note back --- templates/repo/diff/compare.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl index 0c2fc2c32741..4517f0029c79 100644 --- a/templates/repo/diff/compare.tmpl +++ b/templates/repo/diff/compare.tmpl @@ -189,12 +189,13 @@ {{if .HasPullRequest}}
+ {{.i18n.Tr "repo.pulls.has_pull_request" (Escape $.RepoLink) (Escape $.RepoRelPath) .PullRequest.Index | Safe}}

{{RenderIssueTitle .PullRequest.Issue.Title $.RepoLink $.Repository.ComposeMetas}} #{{.PullRequest.Issue.Index}}

-
+
{{- if .PullRequest.HasMerged -}} {{svg "octicon-git-merge" 16}} {{.i18n.Tr "repo.pulls.view"}} {{else if .Issue.IsClosed}}