MCPcopy Create free account
hub / github.com/github/gh-aw / fetchAuditJobLog

Function fetchAuditJobLog

pkg/cli/audit.go:966–990  ·  view source on GitHub ↗
(opts auditJobRunOptions)

Source from the content-addressed store, hash-verified

964}
965
966func fetchAuditJobLog(opts auditJobRunOptions) (string, string, error) {
967 args := []string{"run", "view"}
968 if opts.owner != "" && opts.repo != "" {
969 args = append(args, "-R", fmt.Sprintf("%s/%s", opts.owner, opts.repo))
970 }
971 args = append(args, "--job", strconv.FormatInt(opts.jobID, 10), "--log")
972 if opts.verbose {
973 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Fetching logs for job %d...", opts.jobID)))
974 fmt.Fprintln(os.Stderr, console.FormatVerboseMessage("Executing: gh "+strings.Join(args, " ")))
975 }
976 cmd := workflow.ExecGH(args...)
977 workflow.SetGHHostEnv(cmd, opts.hostname)
978 output, err := cmd.CombinedOutput()
979 if err != nil {
980 return "", "", fmt.Errorf("failed to fetch job logs: %w\nOutput: %s", err, string(output))
981 }
982 jobLogPath := filepath.Join(opts.outputDir, fmt.Sprintf("job-%d.log", opts.jobID))
983 if err := os.WriteFile(jobLogPath, output, constants.FilePermSensitive); err != nil {
984 return "", "", fmt.Errorf("failed to write job log: %w", err)
985 }
986 if opts.verbose {
987 fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Job log saved to "+jobLogPath))
988 }
989 return string(output), jobLogPath, nil
990}
991
992func extractAuditJobDetails(opts auditJobRunOptions, jobLogContent string) error {
993 if opts.stepNumber > 0 {

Callers 1

auditJobRunFunction · 0.85

Calls 6

FormatInfoMessageFunction · 0.92
FormatVerboseMessageFunction · 0.92
ExecGHFunction · 0.92
SetGHHostEnvFunction · 0.92
FormatSuccessMessageFunction · 0.92
ErrorfMethod · 0.45

Tested by

no test coverage detected