Extract shared.GetJob so we can use in rerun too

This commit is contained in:
Cameron Booth 2022-03-03 11:10:22 -08:00
parent ff6c7b925f
commit c38ca830be
2 changed files with 13 additions and 13 deletions

View file

@ -307,6 +307,18 @@ func GetJobs(client *api.Client, repo ghrepo.Interface, run Run) ([]Job, error)
return result.Jobs, nil
}
func GetJob(client *api.Client, repo ghrepo.Interface, jobID string) (*Job, error) {
path := fmt.Sprintf("repos/%s/actions/jobs/%s", ghrepo.FullName(repo), jobID)
var result Job
err := client.REST(repo.RepoHost(), "GET", path, nil, &result)
if err != nil {
return nil, err
}
return &result, nil
}
func PromptForRun(cs *iostreams.ColorScheme, runs []Run) (string, error) {
var selected int
now := time.Now()

View file

@ -183,7 +183,7 @@ func runView(opts *ViewOptions) error {
if jobID != "" {
opts.IO.StartProgressIndicator()
selectedJob, err = getJob(client, repo, jobID)
selectedJob, err = shared.GetJob(client, repo, jobID)
opts.IO.StopProgressIndicator()
if err != nil {
return fmt.Errorf("failed to get job: %w", err)
@ -395,18 +395,6 @@ func runView(opts *ViewOptions) error {
return nil
}
func getJob(client *api.Client, repo ghrepo.Interface, jobID string) (*shared.Job, error) {
path := fmt.Sprintf("repos/%s/actions/jobs/%s", ghrepo.FullName(repo), jobID)
var result shared.Job
err := client.REST(repo.RepoHost(), "GET", path, nil, &result)
if err != nil {
return nil, err
}
return &result, nil
}
func getLog(httpClient *http.Client, logURL string) (io.ReadCloser, error) {
req, err := http.NewRequest("GET", logURL, nil)
if err != nil {