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

Function prLabelList

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

Source from the content-addressed store, hash-verified

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