MCPcopy
hub / github.com/cli/cli / printRawIssuePreview

Function printRawIssuePreview

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

Source from the content-addressed store, hash-verified

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