MCPcopy
hub / github.com/cli/cli / prLabelList

Function prLabelList

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

Source from the content-addressed store, hash-verified

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