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

Function printRawIssuePreview

pkg/cmd/issue/view/view.go:202–243  ·  view source on GitHub ↗
(out io.Writer, issue *api.Issue)

Source from the content-addressed store, hash-verified

200}
201
202func printRawIssuePreview(out io.Writer, issue *api.Issue) error {
203 assignees := issueAssigneeList(*issue)
204 labels := issueLabelList(issue, nil)
205 projects := issueProjectList(*issue)
206
207 // Print empty strings for empty values so the number of metadata lines is consistent when
208 // processing many issues with head and grep.
209 fmt.Fprintf(out, "title:\t%s\n", issue.Title)
210 fmt.Fprintf(out, "state:\t%s\n", issue.State)
211 fmt.Fprintf(out, "author:\t%s\n", issue.Author.DisplayName())
212 fmt.Fprintf(out, "labels:\t%s\n", labels)
213 fmt.Fprintf(out, "comments:\t%d\n", issue.Comments.TotalCount)
214 fmt.Fprintf(out, "assignees:\t%s\n", assignees)
215 fmt.Fprintf(out, "projects:\t%s\n", projects)
216 var milestoneTitle string
217 if issue.Milestone != nil {
218 milestoneTitle = issue.Milestone.Title
219 }
220 fmt.Fprintf(out, "milestone:\t%s\n", milestoneTitle)
221 var issueTypeName string
222 if issue.IssueType != nil {
223 issueTypeName = issue.IssueType.Name
224 }
225 fmt.Fprintf(out, "issue-type:\t%s\n", issueTypeName)
226 var parentRef string
227 if issue.Parent != nil {
228 parentRef = formatLinkedIssueRef(issue.Parent)
229 }
230 fmt.Fprintf(out, "parent:\t%s\n", parentRef)
231 fmt.Fprintf(out, "sub-issues:\t%s\n", formatLinkedIssueRefs(issue.SubIssues.Nodes))
232 var subIssuesCompleted string
233 if issue.SubIssuesSummary.Total > 0 {
234 subIssuesCompleted = fmt.Sprintf("%d/%d", issue.SubIssuesSummary.Completed, issue.SubIssuesSummary.Total)
235 }
236 fmt.Fprintf(out, "sub-issues-completed:\t%s\n", subIssuesCompleted)
237 fmt.Fprintf(out, "blocked-by:\t%s\n", formatLinkedIssueRefs(issue.BlockedBy.Nodes))
238 fmt.Fprintf(out, "blocking:\t%s\n", formatLinkedIssueRefs(issue.Blocking.Nodes))
239 fmt.Fprintf(out, "number:\t%d\n", issue.Number)
240 fmt.Fprintln(out, "--")
241 fmt.Fprintln(out, issue.Body)
242 return nil
243}
244
245func printHumanIssuePreview(opts *ViewOptions, baseRepo ghrepo.Interface, issue *api.Issue) error {
246 out := opts.IO.Out

Callers 1

viewRunFunction · 0.85

Calls 6

issueAssigneeListFunction · 0.85
issueProjectListFunction · 0.85
formatLinkedIssueRefFunction · 0.85
formatLinkedIssueRefsFunction · 0.85
issueLabelListFunction · 0.70
DisplayNameMethod · 0.65

Tested by

no test coverage detected