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

Function runView

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

Source from the content-addressed store, hash-verified

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

Tested by 1

TestViewRunFunction · 0.56