MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / _git_cmd

Function _git_cmd

src/context_system/git_context.py:62–78  ·  view source on GitHub ↗

Run a git command and return stripped stdout or '' on error.

(
    args: list[str],
    cwd: str,
    timeout: float = 5.0,
)

Source from the content-addressed store, hash-verified

60# ---------------------------------------------------------------------------
61
62def _git_cmd(
63 args: list[str],
64 cwd: str,
65 timeout: float = 5.0,
66) -> str:
67 """Run a git command and return stripped stdout or '' on error."""
68 try:
69 result = subprocess.run(
70 ["git", *args],
71 capture_output=True,
72 text=True,
73 cwd=cwd,
74 timeout=timeout,
75 )
76 return result.stdout.strip() if result.returncode == 0 else ""
77 except Exception:
78 return ""
79
80
81def _get_default_branch(cwd: str) -> str:

Callers 5

test_valid_commandMethod · 0.90
test_invalid_commandMethod · 0.90
test_nonexistent_dirMethod · 0.90
_get_default_branchFunction · 0.85
get_is_gitFunction · 0.85

Calls 1

runMethod · 0.45

Tested by 3

test_valid_commandMethod · 0.72
test_invalid_commandMethod · 0.72
test_nonexistent_dirMethod · 0.72