(io *iostreams.IOStreams, comment Comment, newest bool)
| 87 | } |
| 88 | |
| 89 | func formatComment(io *iostreams.IOStreams, comment Comment, newest bool) (string, error) { |
| 90 | var b strings.Builder |
| 91 | cs := io.ColorScheme() |
| 92 | |
| 93 | if comment.IsHidden() { |
| 94 | return cs.Bold(formatHiddenComment(comment)), nil |
| 95 | } |
| 96 | |
| 97 | // Header |
| 98 | fmt.Fprint(&b, cs.Bold(comment.AuthorLogin())) |
| 99 | if comment.Status() != "" { |
| 100 | fmt.Fprint(&b, formatCommentStatus(cs, comment.Status())) |
| 101 | } |
| 102 | if comment.Association() != "NONE" { |
| 103 | fmt.Fprint(&b, cs.Boldf(" (%s)", text.Title(comment.Association()))) |
| 104 | } |
| 105 | fmt.Fprint(&b, cs.Boldf(" • %s", text.FuzzyAgoAbbr(time.Now(), comment.Created()))) |
| 106 | if comment.IsEdited() { |
| 107 | fmt.Fprint(&b, cs.Bold(" • Edited")) |
| 108 | } |
| 109 | if newest { |
| 110 | fmt.Fprint(&b, cs.Bold(" • ")) |
| 111 | fmt.Fprint(&b, cs.CyanBold("Newest comment")) |
| 112 | } |
| 113 | fmt.Fprintln(&b) |
| 114 | |
| 115 | // Reactions |
| 116 | if reactions := ReactionGroupList(comment.Reactions()); reactions != "" { |
| 117 | fmt.Fprint(&b, reactions) |
| 118 | fmt.Fprintln(&b) |
| 119 | } |
| 120 | |
| 121 | // Body |
| 122 | var md string |
| 123 | var err error |
| 124 | if comment.Content() == "" { |
| 125 | md = fmt.Sprintf("\n %s\n\n", cs.Muted("No body provided")) |
| 126 | } else { |
| 127 | md, err = markdown.Render(comment.Content(), |
| 128 | markdown.WithTheme(io.TerminalTheme()), |
| 129 | markdown.WithWrap(io.TerminalWidth())) |
| 130 | if err != nil { |
| 131 | return "", err |
| 132 | } |
| 133 | } |
| 134 | fmt.Fprint(&b, md) |
| 135 | |
| 136 | // Footer |
| 137 | if comment.Link() != "" { |
| 138 | fmt.Fprintf(&b, cs.Muted("View the full review: %s\n\n"), comment.Link()) |
| 139 | } |
| 140 | |
| 141 | return b.String(), nil |
| 142 | } |
| 143 | |
| 144 | func sortComments(cs api.Comments, rs api.PullRequestReviews) []Comment { |
| 145 | comments := cs.Nodes |
no test coverage detected