diff --git a/models/issues/issue_dev_link.go b/models/issues/issue_dev_link.go index bb816ad160..f567d35673 100644 --- a/models/issues/issue_dev_link.go +++ b/models/issues/issue_dev_link.go @@ -21,13 +21,13 @@ const ( ) type IssueDevLink struct { - ID int64 `xorm:"pk autoincr"` - IssueID int64 `xorm:"INDEX"` - LinkType IssueDevLinkType - LinkedRepoID int64 `xorm:"INDEX"` // it can link to self repo or other repo - LinkIndex string // branch name, pull request number or commit sha - CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` - + ID int64 `xorm:"pk autoincr"` + IssueID int64 `xorm:"INDEX"` + LinkType IssueDevLinkType + LinkedRepoID int64 `xorm:"INDEX"` // it can link to self repo or other repo + LinkIndex string // branch name, pull request number or commit sha + CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` + Repo *repo_model.Repository `xorm:"-"` // current repo of issue LinkedRepo *repo_model.Repository `xorm:"-"` PullRequest *PullRequest `xorm:"-"` Branch *git_model.Branch `xorm:"-"` @@ -38,6 +38,13 @@ func init() { db.RegisterModel(new(IssueDevLink)) } +func (i *IssueDevLink) BranchFullName() string { + if i.Repo.ID == i.LinkedRepo.ID { + return i.Branch.Name + } + return i.LinkedRepo.FullName() + ":" + i.Branch.Name +} + // IssueDevLinks represents a list of issue development links type IssueDevLinks []*IssueDevLink diff --git a/services/issue/dev_link.go b/services/issue/dev_link.go index 1e0f4b14c9..8b9633b14d 100644 --- a/services/issue/dev_link.go +++ b/services/issue/dev_link.go @@ -37,6 +37,7 @@ func FindIssueDevLinksByIssue(ctx context.Context, issue *issues_model.Issue) (i branchPRExists := make(container.Set[string]) for _, link := range devLinks { + link.Repo = issue.Repo if link.LinkedRepoID == 0 { link.LinkedRepoID = issue.RepoID } diff --git a/templates/repo/issue/sidebar/development.tmpl b/templates/repo/issue/sidebar/development.tmpl index fc18cf05fd..a1b1b96517 100644 --- a/templates/repo/issue/sidebar/development.tmpl +++ b/templates/repo/issue/sidebar/development.tmpl @@ -11,7 +11,7 @@ {{range .DevLinks}} {{if .PullRequest}}