MCPcopy Index your code
hub / github.com/docker/docker-agent / gitOutput

Function gitOutput

pkg/worktree/worktree.go:404–416  ·  view source on GitHub ↗

gitOutput runs a git command in dir and returns its trimmed stdout.

(ctx context.Context, dir string, args ...string)

Source from the content-addressed store, hash-verified

402
403// gitOutput runs a git command in dir and returns its trimmed stdout.
404func gitOutput(ctx context.Context, dir string, args ...string) (string, error) {
405 cmd := exec.CommandContext(ctx, "git", append([]string{"-C", dir}, args...)...)
406 var stdout, stderr bytes.Buffer
407 cmd.Stdout = &stdout
408 cmd.Stderr = &stderr
409 if err := cmd.Run(); err != nil {
410 if msg := strings.TrimSpace(stderr.String()); msg != "" {
411 return "", fmt.Errorf("%w: %s", err, msg)
412 }
413 return "", err
414 }
415 return strings.TrimSpace(stdout.String()), nil
416}
417
418// gh runs a GitHub CLI command in dir, surfacing its stderr on failure.
419func gh(ctx context.Context, dir string, args ...string) error {

Callers 5

CreateFunction · 0.70
CreatePRFunction · 0.70
StatusMethod · 0.70
repoRootFunction · 0.70
isRemoteFunction · 0.70

Calls 2

StringMethod · 0.95
RunMethod · 0.65

Tested by

no test coverage detected