From 128cc34344104bfe32427a7ecc8422cd7a2918d6 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 22 Jan 2020 11:54:40 +0100 Subject: [PATCH] Fixed repo link in generated comment for cross repository dependency (#9863) (#9935) * fixed link to issue in issue comments after adding/removing a dependency, before links assumed the issue was in the same repository. also changed the format of the displayed issue since the issue will not necessarily be in the same repo * based on pr comments, changed to use HTMLURL instead of piecing together the issue url, and added an if statement around the issue link display as a nil protection * only showing repo name in dependency comment if the issue is from another repo Co-authored-by: Brad Albright <32200834+bhalbright@users.noreply.github.com> Co-authored-by: Antoine GIRARD --- models/issue_comment_list.go | 5 +++ .../repo/issue/view_content/comments.tmpl | 36 ++++++++++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/models/issue_comment_list.go b/models/issue_comment_list.go index ae2a89a01..f8739e32a 100644 --- a/models/issue_comment_list.go +++ b/models/issue_comment_list.go @@ -376,6 +376,11 @@ func (comments CommentList) loadDependentIssues(e Engine) error { for _, comment := range comments { if comment.DependentIssue == nil { comment.DependentIssue = issues[comment.DependentIssueID] + if comment.DependentIssue != nil { + if err := comment.DependentIssue.loadRepo(e); err != nil { + return err + } + } } } return nil diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 658494ac3..40db434de 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -277,10 +277,20 @@ {{$.i18n.Tr "repo.issues.dependency.added_dependency" .Poster.HomeLink (.Poster.GetDisplayName|Escape) $createdStr | Safe}} -
- - #{{.DependentIssue.Index}} {{.DependentIssue.Title}} -
+ {{if .DependentIssue}} +
+ + + + {{if eq .DependentIssue.RepoID .Issue.RepoID}} + #{{.DependentIssue.Index}} {{.DependentIssue.Title}} + {{else}} + {{.DependentIssue.Repo.FullName}}#{{.DependentIssue.Index}} - {{.DependentIssue.Title}} + {{end}} + + +
+ {{end}} {{else if eq .Type 20}}
@@ -291,10 +301,20 @@ {{$.i18n.Tr "repo.issues.dependency.removed_dependency" .Poster.HomeLink (.Poster.GetDisplayName|Escape) $createdStr | Safe}} - + {{if .DependentIssue}} + + {{end}}
{{else if eq .Type 22}}