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

Function printHumanPrPreview

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

Source from the content-addressed store, hash-verified

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

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