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

Function runView

pkg/cmd/run/view/view.go:220–476  ·  view source on GitHub ↗
(opts *ViewOptions)

Source from the content-addressed store, hash-verified

218}
219
220func runView(opts *ViewOptions) error {
221 httpClient, err := opts.HttpClient()
222 if err != nil {
223 return fmt.Errorf("failed to create http client: %w", err)
224 }
225 client := api.NewClientFromHTTP(httpClient)
226
227 repo, err := opts.BaseRepo()
228 if err != nil {
229 return fmt.Errorf("failed to determine base repo: %w", err)
230 }
231
232 jobID := opts.JobID
233 runID := opts.RunID
234 attempt := opts.Attempt
235 var selectedJob *shared.Job
236 var run *shared.Run
237 var jobs []shared.Job
238
239 defer opts.IO.StopProgressIndicator()
240
241 if jobID != "" {
242 opts.IO.StartProgressIndicator()
243 selectedJob, err = shared.GetJob(client, repo, jobID)
244 opts.IO.StopProgressIndicator()
245 if err != nil {
246 return fmt.Errorf("failed to get job: %w", err)
247 }
248 // TODO once more stuff is merged, standardize on using ints
249 runID = fmt.Sprintf("%d", selectedJob.RunID)
250 }
251
252 cs := opts.IO.ColorScheme()
253
254 if opts.Prompt {
255 // TODO arbitrary limit
256 opts.IO.StartProgressIndicator()
257 runs, err := shared.GetRuns(client, repo, nil, 10)
258 opts.IO.StopProgressIndicator()
259 if err != nil {
260 return fmt.Errorf("failed to get runs: %w", err)
261 }
262 runID, err = shared.SelectRun(opts.Prompter, cs, runs.WorkflowRuns)
263 if err != nil {
264 return err
265 }
266 }
267
268 opts.IO.StartProgressIndicator()
269 run, err = shared.GetRun(client, repo, runID, attempt)
270 opts.IO.StopProgressIndicator()
271 if err != nil {
272 return fmt.Errorf("failed to get run: %w", err)
273 }
274
275 if shouldFetchJobs(opts) {
276 opts.IO.StartProgressIndicator()
277 jobs, err = shared.GetJobs(client, repo, run.ID, safeurl.NewImmutableSafeURL(run.JobsURL), attempt)

Callers 3

TestViewRunFunction · 0.70
NewCmdViewFunction · 0.70

Calls 15

StartedTimeMethod · 0.95
NewClientFromHTTPFunction · 0.92
GetJobFunction · 0.92
GetRunsFunction · 0.92
SelectRunFunction · 0.92
GetRunFunction · 0.92
GetJobsFunction · 0.92
NewImmutableSafeURLFunction · 0.92
PullRequestForRunFunction · 0.92
DisplayURLFunction · 0.92
IsFailureStateFunction · 0.92
FullNameFunction · 0.92

Tested by 2

TestViewRunFunction · 0.56