| 346 | } |
| 347 | |
| 348 | func localGit(dir string, env []string, args ...string) (string, error) { |
| 349 | ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout) |
| 350 | defer cancel() |
| 351 | cmd := exec.CommandContext(ctx, "git", args...) |
| 352 | cmd.Dir, cmd.Env = dir, env |
| 353 | containCommand(cmd, false) |
| 354 | var stderr bytes.Buffer |
| 355 | cmd.Stderr = &stderr |
| 356 | out, err := cmd.Output() |
| 357 | if err != nil { |
| 358 | return "", fmt.Errorf("git %s: %w: %s", args[0], err, strings.TrimSpace(stderr.String())) |
| 359 | } |
| 360 | return string(out), nil |
| 361 | } |
| 362 | |
| 363 | func gitBuildDirectory(runID string, index int) string { |
| 364 | return filepath.ToSlash(filepath.Join("git", "runs", runID, strconv.Itoa(index+1))) |