Skip to content
Closed
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
10 changes: 7 additions & 3 deletions pkg/cmd/issue/shared/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func PrintIssues(io *iostreams.IOStreams, prefix string, totalCount int, issues
issueNum = "#" + issueNum
}
issueNum = prefix + issueNum
labels := IssueLabelList(issue, cs)
labels := IssueLabelList(issue, cs, true)
if labels != "" && table.IsTTY() {
labels = fmt.Sprintf("(%s)", labels)
}
Expand Down Expand Up @@ -56,14 +56,18 @@ func truncateLabels(w int, t string) string {
return fmt.Sprintf("(%s)", truncated)
}

func IssueLabelList(issue api.Issue, cs *iostreams.ColorScheme) string {
func IssueLabelList(issue api.Issue, cs *iostreams.ColorScheme, insideCol bool) string {
if len(issue.Labels.Nodes) == 0 {
return ""
}

labelNames := make([]string, 0, len(issue.Labels.Nodes))
for _, label := range issue.Labels.Nodes {
labelNames = append(labelNames, cs.HexToRGB(label.Color, label.Name))
labelName := label.Name
if !insideCol {
labelName = cs.HexToRGB(label.Color, label.Name)
}
labelNames = append(labelNames, labelName)
}

return strings.Join(labelNames, ", ")
Expand Down
5 changes: 2 additions & 3 deletions pkg/cmd/issue/view/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/api"
"github.com/cli/cli/internal/ghrepo"
"github.com/cli/cli/pkg/cmd/issue/shared"
issueShared "github.com/cli/cli/pkg/cmd/issue/shared"
prShared "github.com/cli/cli/pkg/cmd/pr/shared"
"github.com/cli/cli/pkg/cmdutil"
Expand Down Expand Up @@ -143,7 +142,7 @@ func findIssue(client *http.Client, baseRepoFn func() (ghrepo.Interface, error),

func printRawIssuePreview(out io.Writer, issue *api.Issue, cs *iostreams.ColorScheme) error {
assignees := issueAssigneeList(*issue)
labels := shared.IssueLabelList(*issue, cs)
labels := issueShared.IssueLabelList(*issue, cs, false)
projects := issueProjectList(*issue)

// Print empty strings for empty values so the number of metadata lines is consistent when
Expand Down Expand Up @@ -193,7 +192,7 @@ func printHumanIssuePreview(opts *ViewOptions, issue *api.Issue) error {
fmt.Fprint(out, cs.Bold("Assignees: "))
fmt.Fprintln(out, assignees)
}
if labels := shared.IssueLabelList(*issue, cs); labels != "" {
if labels := issueShared.IssueLabelList(*issue, cs, false); labels != "" {
fmt.Fprint(out, cs.Bold("Labels: "))
fmt.Fprintln(out, labels)
}
Expand Down