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

Function printRawIssuePreview

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

Source from the content-addressed store, hash-verified

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