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

Function renderRun

pkg/cmd/run/watch/watch.go:231–298  ·  view source on GitHub ↗
(out io.Writer, opts WatchOptions, client *api.Client, repo ghrepo.Interface, run *shared.Run, prNumber string, annotationCache map[int64][]shared.Annotation)

Source from the content-addressed store, hash-verified

229}
230
231func renderRun(out io.Writer, opts WatchOptions, client *api.Client, repo ghrepo.Interface, run *shared.Run, prNumber string, annotationCache map[int64][]shared.Annotation) (*shared.Run, error) {
232 cs := opts.IO.ColorScheme()
233
234 var err error
235
236 run, err = shared.GetRun(client, repo, fmt.Sprintf("%d", run.ID), 0)
237 if err != nil {
238 return nil, fmt.Errorf("failed to get run: %w", err)
239 }
240
241 jobs, err := shared.GetJobs(client, repo, run.ID, safeurl.NewImmutableSafeURL(run.JobsURL), 0)
242 if err != nil {
243 return nil, fmt.Errorf("failed to get jobs: %w", err)
244 }
245 run.Jobs = jobs
246
247 var annotations []shared.Annotation
248 var missingAnnotationsPermissions bool
249
250 for _, job := range jobs {
251 if as, ok := annotationCache[job.ID]; ok {
252 annotations = as
253 continue
254 }
255
256 as, err := shared.GetAnnotations(client, repo, job)
257 if err != nil {
258 if err != shared.ErrMissingAnnotationsPermissions {
259 return nil, fmt.Errorf("failed to get annotations: %w", err)
260 }
261
262 missingAnnotationsPermissions = true
263 break
264 }
265
266 annotations = append(annotations, as...)
267
268 if job.Status != shared.InProgress {
269 annotationCache[job.ID] = annotations
270 }
271 }
272
273 fmt.Fprintln(out, shared.RenderRunHeader(cs, *run, text.FuzzyAgo(opts.Now(), run.StartedTime()), prNumber, 0))
274 fmt.Fprintln(out)
275
276 if len(jobs) == 0 {
277 return run, nil
278 }
279
280 fmt.Fprintln(out, cs.Bold("JOBS"))
281 if opts.Compact {
282 fmt.Fprintln(out, shared.RenderJobsCompact(cs, jobs))
283 } else {
284 fmt.Fprintln(out, shared.RenderJobs(cs, jobs, true))
285 }
286
287 if missingAnnotationsPermissions {
288 fmt.Fprintln(out)

Callers 1

watchRunFunction · 0.85

Calls 13

GetRunFunction · 0.92
GetJobsFunction · 0.92
NewImmutableSafeURLFunction · 0.92
GetAnnotationsFunction · 0.92
RenderRunHeaderFunction · 0.92
FuzzyAgoFunction · 0.92
RenderJobsCompactFunction · 0.92
RenderJobsFunction · 0.92
RenderAnnotationsFunction · 0.92
ColorSchemeMethod · 0.80
StartedTimeMethod · 0.80
BoldMethod · 0.80

Tested by

no test coverage detected