MCPcopy Create free account
hub / github.com/LegacyCodeHQ/clarity-cli / runGitCommand

Function runGitCommand

vcs/git/git_runner.go:15–36  ·  view source on GitHub ↗
(repoPath string, args ...string)

Source from the content-addressed store, hash-verified

13const gitCommandTimeout = 10 * time.Second
14
15func runGitCommand(repoPath string, args ...string) ([]byte, string, error) {
16 ctx, cancel := context.WithTimeout(context.Background(), gitCommandTimeout)
17 defer cancel()
18
19 cmd := exec.CommandContext(ctx, "git", args...)
20 cmd.Dir = repoPath
21
22 var stdout bytes.Buffer
23 var stderr bytes.Buffer
24 cmd.Stdout = &stdout
25 cmd.Stderr = &stderr
26
27 if err := cmd.Run(); err != nil {
28 stderrText := strings.TrimSpace(stderr.String())
29 if errors.Is(ctx.Err(), context.DeadlineExceeded) {
30 return nil, stderrText, fmt.Errorf("git command timed out after %s", gitCommandTimeout)
31 }
32 return nil, stderrText, err
33 }
34
35 return stdout.Bytes(), strings.TrimSpace(stderr.String()), nil
36}
37
38func gitCommandError(err error, stderr string) error {
39 if err == nil {

Callers 15

getHEADSignatureFunction · 0.85
GetUncommittedFileStatsFunction · 0.85
GetCommitFileStatsFunction · 0.85
GetCommitRangeFileStatsFunction · 0.85
getCommitFileStatusesFunction · 0.85
isGitRepositoryFunction · 0.85
GetRepositoryRootFunction · 0.85
validateCommitFunction · 0.85
GetCurrentCommitHashFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected