MCPcopy
hub / github.com/cli/cli / runRerun

Function runRerun

pkg/cmd/run/rerun/rerun.go:95–186  ·  view source on GitHub ↗
(opts *RerunOptions)

Source from the content-addressed store, hash-verified

93}
94
95func runRerun(opts *RerunOptions) error {
96 c, err := opts.HttpClient()
97 if err != nil {
98 return fmt.Errorf("failed to create http client: %w", err)
99 }
100 client := api.NewClientFromHTTP(c)
101
102 repo, err := opts.BaseRepo()
103 if err != nil {
104 return fmt.Errorf("failed to determine base repo: %w", err)
105 }
106
107 cs := opts.IO.ColorScheme()
108
109 runID := opts.RunID
110 jobID := opts.JobID
111 var selectedJob *shared.Job
112
113 if jobID != "" {
114 opts.IO.StartProgressIndicator()
115 selectedJob, err = shared.GetJob(client, repo, jobID)
116 opts.IO.StopProgressIndicator()
117 if err != nil {
118 return fmt.Errorf("failed to get job: %w", err)
119 }
120 runID = fmt.Sprintf("%d", selectedJob.RunID)
121 }
122
123 if opts.Prompt {
124 runs, err := shared.GetRunsWithFilter(client, repo, nil, 10, func(run shared.Run) bool {
125 if run.Status != shared.Completed {
126 return false
127 }
128 // TODO StartupFailure indicates a bad yaml file; such runs can never be
129 // rerun. But hiding them from the prompt might confuse people?
130 return run.Conclusion != shared.Success && run.Conclusion != shared.StartupFailure
131 })
132 if err != nil {
133 return fmt.Errorf("failed to get runs: %w", err)
134 }
135 if len(runs) == 0 {
136 return errors.New("no recent runs have failed; please specify a specific `<run-id>`")
137 }
138 if runID, err = shared.SelectRun(opts.Prompter, cs, runs); err != nil {
139 return err
140 }
141 }
142
143 debugMsg := ""
144 if opts.Debug {
145 debugMsg = " with debug logging enabled"
146 }
147
148 if opts.JobID != "" {
149 err = rerunJob(client, repo, selectedJob, opts.Debug)
150 if err != nil {
151 return err
152 }

Callers 2

NewCmdRerunFunction · 0.85
TestRerunFunction · 0.85

Calls 15

NewClientFromHTTPFunction · 0.92
GetJobFunction · 0.92
GetRunsWithFilterFunction · 0.92
SelectRunFunction · 0.92
GetRunFunction · 0.92
rerunJobFunction · 0.85
rerunRunFunction · 0.85
ColorSchemeMethod · 0.80
IsStdoutTTYMethod · 0.80
SuccessIconMethod · 0.80
CyanfMethod · 0.80
ErrorfMethod · 0.65

Tested by 1

TestRerunFunction · 0.68