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

Function runView

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

Source from the content-addressed store, hash-verified

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