Skip to content

Commit c38ca83

Browse files
committed
Extract shared.GetJob so we can use in rerun too
1 parent ff6c7b9 commit c38ca83

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

pkg/cmd/run/shared/shared.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,18 @@ func GetJobs(client *api.Client, repo ghrepo.Interface, run Run) ([]Job, error)
307307
return result.Jobs, nil
308308
}
309309

310+
func GetJob(client *api.Client, repo ghrepo.Interface, jobID string) (*Job, error) {
311+
path := fmt.Sprintf("repos/%s/actions/jobs/%s", ghrepo.FullName(repo), jobID)
312+
313+
var result Job
314+
err := client.REST(repo.RepoHost(), "GET", path, nil, &result)
315+
if err != nil {
316+
return nil, err
317+
}
318+
319+
return &result, nil
320+
}
321+
310322
func PromptForRun(cs *iostreams.ColorScheme, runs []Run) (string, error) {
311323
var selected int
312324
now := time.Now()

pkg/cmd/run/view/view.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func runView(opts *ViewOptions) error {
183183

184184
if jobID != "" {
185185
opts.IO.StartProgressIndicator()
186-
selectedJob, err = getJob(client, repo, jobID)
186+
selectedJob, err = shared.GetJob(client, repo, jobID)
187187
opts.IO.StopProgressIndicator()
188188
if err != nil {
189189
return fmt.Errorf("failed to get job: %w", err)
@@ -395,18 +395,6 @@ func runView(opts *ViewOptions) error {
395395
return nil
396396
}
397397

398-
func getJob(client *api.Client, repo ghrepo.Interface, jobID string) (*shared.Job, error) {
399-
path := fmt.Sprintf("repos/%s/actions/jobs/%s", ghrepo.FullName(repo), jobID)
400-
401-
var result shared.Job
402-
err := client.REST(repo.RepoHost(), "GET", path, nil, &result)
403-
if err != nil {
404-
return nil, err
405-
}
406-
407-
return &result, nil
408-
}
409-
410398
func getLog(httpClient *http.Client, logURL string) (io.ReadCloser, error) {
411399
req, err := http.NewRequest("GET", logURL, nil)
412400
if err != nil {

0 commit comments

Comments
 (0)