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

Function printRawIssuePreview

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

Source from the content-addressed store, hash-verified

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