MCPcopy Create free account
hub / github.com/cli/cli / prLabelList

Function prLabelList

pkg/cmd/pr/view/view.go:442–462  ·  view source on GitHub ↗
(pr api.PullRequest, cs *iostreams.ColorScheme)

Source from the content-addressed store, hash-verified

440}
441
442func prLabelList(pr api.PullRequest, cs *iostreams.ColorScheme) string {
443 if len(pr.Labels.Nodes) == 0 {
444 return ""
445 }
446
447 // ignore case sort
448 sort.SliceStable(pr.Labels.Nodes, func(i, j int) bool {
449 return strings.ToLower(pr.Labels.Nodes[i].Name) < strings.ToLower(pr.Labels.Nodes[j].Name)
450 })
451
452 labelNames := make([]string, 0, len(pr.Labels.Nodes))
453 for _, label := range pr.Labels.Nodes {
454 labelNames = append(labelNames, cs.Label(label.Color, label.Name))
455 }
456
457 list := strings.Join(labelNames, ", ")
458 if pr.Labels.TotalCount > len(pr.Labels.Nodes) {
459 list += ", …"
460 }
461 return list
462}
463
464func prProjectList(pr api.PullRequest) string {
465 totalCount := pr.ProjectCards.TotalCount + pr.ProjectItems.TotalCount

Callers 2

printRawPrPreviewFunction · 0.85
printHumanPrPreviewFunction · 0.85

Calls 2

JoinMethod · 0.80
LabelMethod · 0.45

Tested by

no test coverage detected