Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show source/target branches on PR's list #19747

Merged
merged 16 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions models/issue_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ const (
defaultMaxInSize = 50
)

// get the repo IDs to be loaded later, these IDs are for issue.Repo and issue.PullRequest.HeadRepo
func (issues IssueList) getRepoIDs() []int64 {
repoIDs := make(map[int64]struct{}, len(issues))
for _, issue := range issues {
if issue.Repo != nil {
continue
}
if _, ok := repoIDs[issue.RepoID]; !ok {
if issue.Repo == nil {
repoIDs[issue.RepoID] = struct{}{}
}
if issue.PullRequest != nil && issue.PullRequest.HeadRepo == nil {
repoIDs[issue.PullRequest.HeadRepoID] = struct{}{}
}
}
return container.KeysInt64(repoIDs)
}
Expand Down Expand Up @@ -67,8 +68,11 @@ func (issues IssueList) loadRepositories(ctx context.Context) ([]*repo_model.Rep
} else {
repoMaps[issue.RepoID] = issue.Repo
}
if issue.PullRequest != nil && issue.PullRequest.BaseRepo == nil {
if issue.PullRequest != nil {
issue.PullRequest.BaseRepo = issue.Repo
if issue.PullRequest.HeadRepo == nil {
issue.PullRequest.HeadRepo = repoMaps[issue.PullRequest.HeadRepoID]
}
}
}
return valuesRepository(repoMaps), nil
Expand Down
21 changes: 21 additions & 0 deletions templates/shared/issuelist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,27 @@
{{else}}
{{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}}
{{end}}
{{if .IsPull}}
<div class="branches">
<div class="branch">
<a class="bold" href="{{.PullRequest.BaseRepo.HTMLURL}}/src/branch/{{PathEscapeSegments .PullRequest.BaseBranch}}">
{{/* inline to remove the spaces between spans */}}
{{if ne .RepoID .PullRequest.BaseRepoID}}<span class="truncated-name">{{.PullRequest.BaseRepo.OwnerName}}</span>:{{end}}<span class="truncated-name">{{.PullRequest.BaseBranch}}</span>
</a>
</div>

&laquo;

{{if .PullRequest.HeadRepo}}
<div class="branch">
<a class="bold" href="{{.PullRequest.HeadRepo.HTMLURL}}/src/branch/{{PathEscapeSegments .PullRequest.HeadBranch}}">
{{/* inline to remove the spaces between spans */}}
{{if ne .RepoID .PullRequest.HeadRepoID}}<span class="truncated-name">{{.PullRequest.HeadRepo.OwnerName}}</span>:{{end}}<span class="truncated-name">{{.PullRequest.HeadBranch}}</span>
</a>
</div>
{{end}}
</div>
{{end}}
{{if and .Milestone (ne $.listType "milestone")}}
<a class="milestone" {{if $.RepoLink}}href="{{$.RepoLink}}/milestone/{{.Milestone.ID}}"{{else}}href="{{.Repo.Link}}/milestone/{{.Milestone.ID}}"{{end}}>
{{svg "octicon-milestone" 14 "mr-2"}}{{.Milestone.Name}}
Expand Down
17 changes: 17 additions & 0 deletions web_src/less/shared/issuelist.less
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@
}
}

.branches {
display: inline-flex;
padding: 0 6px;

.branch {
background-color: var(--color-secondary);
border-radius: 3px;
}

.truncated-name {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 10em;
}
}

> .item + .item {
border-top: 1px solid var(--color-secondary);
}
Expand Down