MCPcopy
hub / github.com/cli/cli / printHumanPrPreview

Function printHumanPrPreview

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

Source from the content-addressed store, hash-verified

180}
181
182func printHumanPrPreview(opts *ViewOptions, baseRepo ghrepo.Interface, pr *api.PullRequest) error {
183 out := opts.IO.Out
184 cs := opts.IO.ColorScheme()
185
186 // Header (Title and State)
187 fmt.Fprintf(out, "%s %s#%d\n", cs.Bold(pr.Title), ghrepo.FullName(baseRepo), pr.Number)
188 fmt.Fprintf(out,
189 "%s • %s wants to merge %s into %s from %s • %s\n",
190 shared.StateTitleWithColor(cs, *pr),
191 pr.Author.DisplayName(),
192 text.Pluralize(pr.Commits.TotalCount, "commit"),
193 pr.BaseRefName,
194 pr.HeadRefName,
195 text.FuzzyAgo(opts.Now(), pr.CreatedAt),
196 )
197
198 // added/removed
199 fmt.Fprintf(out,
200 "%s %s",
201 cs.Green("+"+strconv.Itoa(pr.Additions)),
202 cs.Red("-"+strconv.Itoa(pr.Deletions)),
203 )
204
205 // checks
206 checks := pr.ChecksStatus()
207 if summary := shared.PrCheckStatusSummaryWithColor(cs, checks); summary != "" {
208 fmt.Fprintf(out, " • %s\n", summary)
209 } else {
210 fmt.Fprintln(out)
211 }
212
213 // Reactions
214 if reactions := shared.ReactionGroupList(pr.ReactionGroups); reactions != "" {
215 fmt.Fprint(out, reactions)
216 fmt.Fprintln(out)
217 }
218
219 // Metadata
220 if reviewers := prReviewerList(*pr, cs); reviewers != "" {
221 fmt.Fprint(out, cs.Bold("Reviewers: "))
222 fmt.Fprintln(out, reviewers)
223 }
224 if assignees := prAssigneeList(*pr); assignees != "" {
225 fmt.Fprint(out, cs.Bold("Assignees: "))
226 fmt.Fprintln(out, assignees)
227 }
228 if labels := prLabelList(*pr, cs); labels != "" {
229 fmt.Fprint(out, cs.Bold("Labels: "))
230 fmt.Fprintln(out, labels)
231 }
232 if projects := prProjectList(*pr); projects != "" {
233 fmt.Fprint(out, cs.Bold("Projects: "))
234 fmt.Fprintln(out, projects)
235 }
236 if pr.Milestone != nil {
237 fmt.Fprint(out, cs.Bold("Milestone: "))
238 fmt.Fprintln(out, pr.Milestone.Title)
239 }

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