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

Function renderRun

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

213}
214
215func 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) {
216 cs := opts.IO.ColorScheme()
217
218 var err error
219
220 run, err = shared.GetRun(client, repo, fmt.Sprintf("%d", run.ID), 0)
221 if err != nil {
222 return nil, fmt.Errorf("failed to get run: %w", err)
223 }
224
225 jobs, err := shared.GetJobs(client, repo, run.ID, safeurl.NewImmutableSafeURL(run.JobsURL), 0)
226 if err != nil {
227 return nil, fmt.Errorf("failed to get jobs: %w", err)
228 }
229 run.Jobs = jobs
230
231 var annotations []shared.Annotation
232 var missingAnnotationsPermissions bool
233
234 for _, job := range jobs {
235 if as, ok := annotationCache[job.ID]; ok {
236 annotations = as
237 continue
238 }
239
240 as, err := shared.GetAnnotations(client, repo, job)
241 if err != nil {
242 if err != shared.ErrMissingAnnotationsPermissions {
243 return nil, fmt.Errorf("failed to get annotations: %w", err)
244 }
245
246 missingAnnotationsPermissions = true
247 break
248 }
249
250 annotations = append(annotations, as...)
251
252 if job.Status != shared.InProgress {
253 annotationCache[job.ID] = annotations
254 }
255 }
256
257 fmt.Fprintln(out, shared.RenderRunHeader(cs, *run, text.FuzzyAgo(opts.Now(), run.StartedTime()), prNumber, 0))
258 fmt.Fprintln(out)
259
260 if len(jobs) == 0 {
261 return run, nil
262 }
263
264 fmt.Fprintln(out, cs.Bold("JOBS"))
265 if opts.Compact {
266 fmt.Fprintln(out, shared.RenderJobsCompact(cs, jobs))
267 } else {
268 fmt.Fprintln(out, shared.RenderJobs(cs, jobs, true))
269 }
270
271 if missingAnnotationsPermissions {
272 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