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

Function renderRun

pkg/cmd/run/watch/watch.go:236–303  ·  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

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