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

Function runView

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

Source from the content-addressed store, hash-verified

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