Skip to content

Commit 2f7a747

Browse files
bhalbrightsapk
authored andcommitted
Fixed repo link in generated comment for cross repository dependency (#9863)
* 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: Antoine GIRARD <[email protected]>
1 parent 5cf241b commit 2f7a747

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

models/issue_comment_list.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@ func (comments CommentList) loadDependentIssues(e Engine) error {
376376
for _, comment := range comments {
377377
if comment.DependentIssue == nil {
378378
comment.DependentIssue = issues[comment.DependentIssueID]
379+
if comment.DependentIssue != nil {
380+
if err := comment.DependentIssue.loadRepo(e); err != nil {
381+
return err
382+
}
383+
}
379384
}
380385
}
381386
return nil

templates/repo/issue/view_content/comments.tmpl

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,20 @@
277277
<span class="text grey">
278278
{{$.i18n.Tr "repo.issues.dependency.added_dependency" .Poster.HomeLink (.Poster.GetDisplayName|Escape) $createdStr | Safe}}
279279
</span>
280-
<div class="detail">
281-
<span class="octicon octicon-plus"></span>
282-
<span class="text grey"><a href="{{$.RepoLink}}/issues/{{.DependentIssue.Index}}">#{{.DependentIssue.Index}} {{.DependentIssue.Title}}</a></span>
283-
</div>
280+
{{if .DependentIssue}}
281+
<div class="detail">
282+
<span class="octicon octicon-plus"></span>
283+
<span class="text grey">
284+
<a href="{{.DependentIssue.HTMLURL}}">
285+
{{if eq .DependentIssue.RepoID .Issue.RepoID}}
286+
#{{.DependentIssue.Index}} {{.DependentIssue.Title}}
287+
{{else}}
288+
{{.DependentIssue.Repo.FullName}}#{{.DependentIssue.Index}} - {{.DependentIssue.Title}}
289+
{{end}}
290+
</a>
291+
</span>
292+
</div>
293+
{{end}}
284294
</div>
285295
{{else if eq .Type 20}}
286296
<div class="event" id="{{.HashTag}}">
@@ -291,10 +301,20 @@
291301
<span class="text grey">
292302
{{$.i18n.Tr "repo.issues.dependency.removed_dependency" .Poster.HomeLink (.Poster.GetDisplayName|Escape) $createdStr | Safe}}
293303
</span>
294-
<div class="detail">
295-
<span class="text grey octicon octicon-trashcan"></span>
296-
<span class="text grey"><a href="{{$.RepoLink}}/issues/{{.DependentIssue.Index}}">#{{.DependentIssue.Index}} {{.DependentIssue.Title}}</a></span>
297-
</div>
304+
{{if .DependentIssue}}
305+
<div class="detail">
306+
<span class="text grey octicon octicon-trashcan"></span>
307+
<span class="text grey">
308+
<a href="{{.DependentIssue.HTMLURL}}">
309+
{{if eq .DependentIssue.RepoID .Issue.RepoID}}
310+
#{{.DependentIssue.Index}} {{.DependentIssue.Title}}
311+
{{else}}
312+
{{.DependentIssue.Repo.FullName}}#{{.DependentIssue.Index}} - {{.DependentIssue.Title}}
313+
{{end}}
314+
</a>
315+
</span>
316+
</div>
317+
{{end}}
298318
</div>
299319
{{else if eq .Type 22}}
300320
<div class="event" id="{{.HashTag}}">

0 commit comments

Comments
 (0)