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

Function printHumanPrPreview

pkg/cmd/pr/view/view.go:205–316  ·  view source on GitHub ↗
(opts *ViewOptions, baseRepo ghrepo.Interface, pr *api.PullRequest)

Source from the content-addressed store, hash-verified

203}
204
205func printHumanPrPreview(opts *ViewOptions, baseRepo ghrepo.Interface, pr *api.PullRequest) error {
206 out := opts.IO.Out
207 cs := opts.IO.ColorScheme()
208
209 // Header (Title and State)
210 fmt.Fprintf(out, "%s %s#%d\n", cs.Bold(pr.Title), ghrepo.FullName(baseRepo), pr.Number)
211 fmt.Fprintf(out,
212 "%s • %s wants to merge %s into %s from %s • %s\n",
213 shared.StateTitleWithColor(cs, *pr),
214 pr.Author.DisplayName(),
215 text.Pluralize(pr.Commits.TotalCount, "commit"),
216 pr.BaseRefName,
217 pr.HeadRefName,
218 text.FuzzyAgo(opts.Now(), pr.CreatedAt),
219 )
220
221 // added/removed
222 fmt.Fprintf(out,
223 "%s %s",
224 cs.Green("+"+strconv.Itoa(pr.Additions)),
225 cs.Red("-"+strconv.Itoa(pr.Deletions)),
226 )
227
228 // checks
229 checks := pr.ChecksStatus()
230 if summary := shared.PrCheckStatusSummaryWithColor(cs, checks); summary != "" {
231 fmt.Fprintf(out, " • %s\n", summary)
232 } else {
233 fmt.Fprintln(out)
234 }
235
236 // Reactions
237 if reactions := shared.ReactionGroupList(pr.ReactionGroups); reactions != "" {
238 fmt.Fprint(out, reactions)
239 fmt.Fprintln(out)
240 }
241
242 // Metadata
243 if reviewers := prReviewerList(*pr, cs); reviewers != "" {
244 fmt.Fprint(out, cs.Bold("Reviewers: "))
245 fmt.Fprintln(out, reviewers)
246 }
247 if assignees := prAssigneeList(*pr); assignees != "" {
248 fmt.Fprint(out, cs.Bold("Assignees: "))
249 fmt.Fprintln(out, assignees)
250 }
251 if labels := prLabelList(*pr, cs); labels != "" {
252 fmt.Fprint(out, cs.Bold("Labels: "))
253 fmt.Fprintln(out, labels)
254 }
255 if projects := prProjectList(*pr); projects != "" {
256 fmt.Fprint(out, cs.Bold("Projects: "))
257 fmt.Fprintln(out, projects)
258 }
259 if pr.Milestone != nil {
260 fmt.Fprint(out, cs.Bold("Milestone: "))
261 fmt.Fprintln(out, pr.Milestone.Title)
262 }

Callers 1

viewRunFunction · 0.85

Calls 15

FullNameFunction · 0.92
StateTitleWithColorFunction · 0.92
PluralizeFunction · 0.92
FuzzyAgoFunction · 0.92
ReactionGroupListFunction · 0.92
RenderFunction · 0.92
WithThemeFunction · 0.92
WithWrapFunction · 0.92
CommentListFunction · 0.92
prReviewerListFunction · 0.85
prAssigneeListFunction · 0.85

Tested by

no test coverage detected