MCPcopy Create free account
hub / github.com/cli/cli / localGit

Function localGit

script/ghmock/gitcmd.go:348–361  ·  view source on GitHub ↗
(dir string, env []string, args ...string)

Source from the content-addressed store, hash-verified

346}
347
348func 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
363func gitBuildDirectory(runID string, index int) string {
364 return filepath.ToSlash(filepath.Join("git", "runs", runID, strconv.Itoa(index+1)))

Callers 2

runBinaryFunction · 0.85
cmdRepoFunction · 0.85

Calls 4

containCommandFunction · 0.70
OutputMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected