Run a git command and return stripped stdout or '' on error.
(
args: list[str],
cwd: str,
timeout: float = 5.0,
)
| 60 | # --------------------------------------------------------------------------- |
| 61 | |
| 62 | def _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 | |
| 81 | def _get_default_branch(cwd: str) -> str: |