MCPcopy Index your code
hub / github.com/cli/cli / getRunLog

Function getRunLog

pkg/cmd/run/view/view.go:490–532  ·  view source on GitHub ↗
(cache RunLogCache, httpClient *http.Client, repo ghrepo.Interface, run *shared.Run, attempt uint64)

Source from the content-addressed store, hash-verified

488}
489
490func getRunLog(cache RunLogCache, httpClient *http.Client, repo ghrepo.Interface, run *shared.Run, attempt uint64) (*zip.ReadCloser, error) {
491 cacheKey := fmt.Sprintf("%d-%d", run.ID, run.StartedTime().Unix())
492 isCached, err := cache.Exists(cacheKey)
493 if err != nil {
494 return nil, err
495 }
496
497 if !isCached {
498 // Run log does not exist in cache so retrieve and store it
499 logURL := fmt.Sprintf("%srepos/%s/actions/runs/%d/logs",
500 ghinstance.RESTPrefix(repo.RepoHost()), ghrepo.FullName(repo), run.ID)
501
502 if attempt > 0 {
503 logURL = fmt.Sprintf("%srepos/%s/actions/runs/%d/attempts/%d/logs",
504 ghinstance.RESTPrefix(repo.RepoHost()), ghrepo.FullName(repo), run.ID, attempt)
505 }
506
507 resp, err := getLog(httpClient, logURL)
508 if err != nil {
509 return nil, err
510 }
511 defer resp.Close()
512
513 data, err := io.ReadAll(resp)
514 if err != nil {
515 return nil, err
516 }
517 respReader := bytes.NewReader(data)
518
519 // Check if the response is a valid zip format
520 _, err = zip.NewReader(respReader, respReader.Size())
521 if err != nil {
522 return nil, err
523 }
524
525 err = cache.Create(cacheKey, respReader)
526 if err != nil {
527 return nil, err
528 }
529 }
530
531 return cache.Open(cacheKey)
532}
533
534func promptForJob(prompter shared.Prompter, cs *iostreams.ColorScheme, jobs []shared.Job) (*shared.Job, error) {
535 candidates := []string{"View all jobs in this run"}

Callers 1

runViewFunction · 0.85

Calls 10

RESTPrefixFunction · 0.92
FullNameFunction · 0.92
getLogFunction · 0.85
StartedTimeMethod · 0.80
ExistsMethod · 0.80
OpenMethod · 0.80
RepoHostMethod · 0.65
CloseMethod · 0.65
SizeMethod · 0.65
CreateMethod · 0.65

Tested by

no test coverage detected