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

Function runView

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

Source from the content-addressed store, hash-verified

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