Run a git command, return stdout or None on failure.
(cwd: Path, *args: str, timeout: int = 60)
| 56 | |
| 57 | |
| 58 | def _run_git(cwd: Path, *args: str, timeout: int = 60) -> Optional[str]: |
| 59 | """Run a git command, return stdout or None on failure.""" |
| 60 | try: |
| 61 | result = subprocess.run( |
| 62 | ["git", *args], |
| 63 | cwd=str(cwd), |
| 64 | capture_output=True, |
| 65 | text=True, |
| 66 | timeout=timeout, |
| 67 | ) |
| 68 | if result.returncode == 0: |
| 69 | return result.stdout.strip() |
| 70 | return None |
| 71 | except Exception: |
| 72 | return None |
| 73 | |
| 74 | |
| 75 | def _backup_large_file( |
no test coverage detected