@@ -10,7 +10,6 @@ import (
1010 "github.com/MakeNowJust/heredoc"
1111 "github.com/cli/cli/api"
1212 "github.com/cli/cli/internal/ghrepo"
13- "github.com/cli/cli/pkg/cmd/issue/shared"
1413 issueShared "github.com/cli/cli/pkg/cmd/issue/shared"
1514 prShared "github.com/cli/cli/pkg/cmd/pr/shared"
1615 "github.com/cli/cli/pkg/cmdutil"
@@ -125,7 +124,7 @@ func viewRun(opts *ViewOptions) error {
125124 return nil
126125 }
127126
128- return printRawIssuePreview (opts .IO .Out , issue , opts . IO . ColorScheme () )
127+ return printRawIssuePreview (opts .IO .Out , issue )
129128}
130129
131130func findIssue (client * http.Client , baseRepoFn func () (ghrepo.Interface , error ), selector string , loadComments bool ) (* api.Issue , error ) {
@@ -141,9 +140,9 @@ func findIssue(client *http.Client, baseRepoFn func() (ghrepo.Interface, error),
141140 return issue , err
142141}
143142
144- func printRawIssuePreview (out io.Writer , issue * api.Issue , cs * iostreams. ColorScheme ) error {
143+ func printRawIssuePreview (out io.Writer , issue * api.Issue ) error {
145144 assignees := issueAssigneeList (* issue )
146- labels := shared . IssueLabelList ( * issue , cs )
145+ labels := issueLabelList ( issue , nil )
147146 projects := issueProjectList (* issue )
148147
149148 // Print empty strings for empty values so the number of metadata lines is consistent when
@@ -193,7 +192,7 @@ func printHumanIssuePreview(opts *ViewOptions, issue *api.Issue) error {
193192 fmt .Fprint (out , cs .Bold ("Assignees: " ))
194193 fmt .Fprintln (out , assignees )
195194 }
196- if labels := shared . IssueLabelList ( * issue , cs ); labels != "" {
195+ if labels := issueLabelList ( issue , cs ); labels != "" {
197196 fmt .Fprint (out , cs .Bold ("Labels: " ))
198197 fmt .Fprintln (out , labels )
199198 }
@@ -278,3 +277,20 @@ func issueProjectList(issue api.Issue) string {
278277 }
279278 return list
280279}
280+
281+ func issueLabelList (issue * api.Issue , cs * iostreams.ColorScheme ) string {
282+ if len (issue .Labels .Nodes ) == 0 {
283+ return ""
284+ }
285+
286+ labelNames := make ([]string , len (issue .Labels .Nodes ))
287+ for i , label := range issue .Labels .Nodes {
288+ if cs == nil {
289+ labelNames [i ] = label .Name
290+ } else {
291+ labelNames [i ] = cs .HexToRGB (label .Color , label .Name )
292+ }
293+ }
294+
295+ return strings .Join (labelNames , ", " )
296+ }
0 commit comments