Display forked repository's branch

This commit is contained in:
Lunny Xiao 2024-11-28 16:13:40 -08:00
parent 703eebfa92
commit ab6d2ed9d7
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 20 additions and 12 deletions

View File

@ -27,7 +27,7 @@ type IssueDevLink struct {
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

View File

@ -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
}

View File

@ -11,7 +11,7 @@
{{range .DevLinks}}
{{if .PullRequest}}
<div class="tw-flex tw-items-center tw-overflow-hidden tw-max-w-full">
{{template "shared/issueicon" .PullRequest.Issue}}
<span class="tw-mr-1">{{template "shared/issueicon" .PullRequest.Issue}}</span>
<a href="{{.PullRequest.Issue.Link}}" data-tooltip-content="{{.PullRequest.Issue.Title}}" class="item tw-overflow-hidden gt-ellipsis tw-whitespace-nowrap">
{{.PullRequest.Issue.Title}}
</a>
@ -22,7 +22,7 @@
{{ctx.Locale.Tr "repo.issues.pr.completed"}}
</div>
<div class="tw-flex tw-items-center tw-overflow-hidden tw-max-w-full">
{{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>
{{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>
</div>
<div>
{{ctx.Locale.Tr "repo.issues.link.created" (DateUtils.AbsoluteShort .PullRequest.MergedUnix)}}
@ -33,9 +33,9 @@
{{else if and .Branch .DisplayBranch}}
<div class="tw-flex tw-justify-between tw-items-center">
<div class="tw-flex tw-left tw-items-center tw-overflow-hidden tw-max-w-full">
{{svg "octicon-git-branch" 14}}
<a href="{{.Branch.Repo.Link}}/src/branch/{{.Branch.Name}}" data-tooltip-content="{{.Branch.Name}}" class="tw-overflow-hidden gt-ellipsis tw-whitespace-nowrap">
{{.Branch.Name}}
{{svg "octicon-git-branch" 14 "tw-mr-1"}}
<a href="{{.Branch.Repo.Link}}/src/branch/{{.Branch.Name}}" data-tooltip-content="{{.BranchFullName}}" class="tw-overflow-hidden gt-ellipsis tw-whitespace-nowrap">
{{.BranchFullName}}
</a>
</div>
<div class="tw-right tw-items-center">