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

Function prLabelList

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

Source from the content-addressed store, hash-verified

422}
423
424func prLabelList(pr api.PullRequest, cs *iostreams.ColorScheme) string {
425 if len(pr.Labels.Nodes) == 0 {
426 return ""
427 }
428
429 // ignore case sort
430 sort.SliceStable(pr.Labels.Nodes, func(i, j int) bool {
431 return strings.ToLower(pr.Labels.Nodes[i].Name) < strings.ToLower(pr.Labels.Nodes[j].Name)
432 })
433
434 labelNames := make([]string, 0, len(pr.Labels.Nodes))
435 for _, label := range pr.Labels.Nodes {
436 labelNames = append(labelNames, cs.Label(label.Color, label.Name))
437 }
438
439 list := strings.Join(labelNames, ", ")
440 if pr.Labels.TotalCount > len(pr.Labels.Nodes) {
441 list += ", …"
442 }
443 return list
444}
445
446func prProjectList(pr api.PullRequest) string {
447 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