MCPcopy
hub / github.com/cli/cli / runView

Function runView

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

Source from the content-addressed store, hash-verified

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

Callers 2

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
DisplayURLFunction · 0.92
IsFailureStateFunction · 0.92
PullRequestForRunFunction · 0.92
FullNameFunction · 0.92
ListArtifactsFunction · 0.92

Tested by 1

TestViewRunFunction · 0.56