Skip to content

Commit ab6d2ed

Browse files
committed
Display forked repository's branch
1 parent 703eebf commit ab6d2ed

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

models/issues/issue_dev_link.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ const (
2121
)
2222

2323
type IssueDevLink struct {
24-
ID int64 `xorm:"pk autoincr"`
25-
IssueID int64 `xorm:"INDEX"`
26-
LinkType IssueDevLinkType
27-
LinkedRepoID int64 `xorm:"INDEX"` // it can link to self repo or other repo
28-
LinkIndex string // branch name, pull request number or commit sha
29-
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
30-
24+
ID int64 `xorm:"pk autoincr"`
25+
IssueID int64 `xorm:"INDEX"`
26+
LinkType IssueDevLinkType
27+
LinkedRepoID int64 `xorm:"INDEX"` // it can link to self repo or other repo
28+
LinkIndex string // branch name, pull request number or commit sha
29+
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
30+
Repo *repo_model.Repository `xorm:"-"` // current repo of issue
3131
LinkedRepo *repo_model.Repository `xorm:"-"`
3232
PullRequest *PullRequest `xorm:"-"`
3333
Branch *git_model.Branch `xorm:"-"`
@@ -38,6 +38,13 @@ func init() {
3838
db.RegisterModel(new(IssueDevLink))
3939
}
4040

41+
func (i *IssueDevLink) BranchFullName() string {
42+
if i.Repo.ID == i.LinkedRepo.ID {
43+
return i.Branch.Name
44+
}
45+
return i.LinkedRepo.FullName() + ":" + i.Branch.Name
46+
}
47+
4148
// IssueDevLinks represents a list of issue development links
4249
type IssueDevLinks []*IssueDevLink
4350

services/issue/dev_link.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func FindIssueDevLinksByIssue(ctx context.Context, issue *issues_model.Issue) (i
3737
branchPRExists := make(container.Set[string])
3838

3939
for _, link := range devLinks {
40+
link.Repo = issue.Repo
4041
if link.LinkedRepoID == 0 {
4142
link.LinkedRepoID = issue.RepoID
4243
}

templates/repo/issue/sidebar/development.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{range .DevLinks}}
1212
{{if .PullRequest}}
1313
<div class="tw-flex tw-items-center tw-overflow-hidden tw-max-w-full">
14-
{{template "shared/issueicon" .PullRequest.Issue}}
14+
<span class="tw-mr-1">{{template "shared/issueicon" .PullRequest.Issue}}</span>
1515
<a href="{{.PullRequest.Issue.Link}}" data-tooltip-content="{{.PullRequest.Issue.Title}}" class="item tw-overflow-hidden gt-ellipsis tw-whitespace-nowrap">
1616
{{.PullRequest.Issue.Title}}
1717
</a>
@@ -22,7 +22,7 @@
2222
{{ctx.Locale.Tr "repo.issues.pr.completed"}}
2323
</div>
2424
<div class="tw-flex tw-items-center tw-overflow-hidden tw-max-w-full">
25-
{{svg "octicon-git-commit" 14}} <a href="{{.PullRequest.BaseRepo.Link}}/src/commit/{{.PullRequest.MergedCommitID}}" data-tooltip-content="{{.PullRequest.MergedCommitID}}" class="tw-overflow-hidden gt-ellipsis tw-whitespace-nowrap">{{.PullRequest.MergedCommitID | ShortSha}}</a>
25+
{{svg "octicon-git-commit" 14 "tw-mr-1"}} <a href="{{.PullRequest.BaseRepo.Link}}/src/commit/{{.PullRequest.MergedCommitID}}" data-tooltip-content="{{.PullRequest.MergedCommitID}}" class="tw-overflow-hidden gt-ellipsis tw-whitespace-nowrap">{{.PullRequest.MergedCommitID | ShortSha}}</a>
2626
</div>
2727
<div>
2828
{{ctx.Locale.Tr "repo.issues.link.created" (DateUtils.AbsoluteShort .PullRequest.MergedUnix)}}
@@ -33,9 +33,9 @@
3333
{{else if and .Branch .DisplayBranch}}
3434
<div class="tw-flex tw-justify-between tw-items-center">
3535
<div class="tw-flex tw-left tw-items-center tw-overflow-hidden tw-max-w-full">
36-
{{svg "octicon-git-branch" 14}}
37-
<a href="{{.Branch.Repo.Link}}/src/branch/{{.Branch.Name}}" data-tooltip-content="{{.Branch.Name}}" class="tw-overflow-hidden gt-ellipsis tw-whitespace-nowrap">
38-
{{.Branch.Name}}
36+
{{svg "octicon-git-branch" 14 "tw-mr-1"}}
37+
<a href="{{.Branch.Repo.Link}}/src/branch/{{.Branch.Name}}" data-tooltip-content="{{.BranchFullName}}" class="tw-overflow-hidden gt-ellipsis tw-whitespace-nowrap">
38+
{{.BranchFullName}}
3939
</a>
4040
</div>
4141
<div class="tw-right tw-items-center">

0 commit comments

Comments
 (0)