|
6 | 6 | import uuid |
7 | 7 | import threading |
8 | 8 | import subprocess |
| 9 | +import shutil |
9 | 10 | from datetime import datetime |
10 | 11 | from typing import List, Optional, Any, Dict, Tuple |
11 | 12 | from contextlib import contextmanager, nullcontext |
@@ -88,8 +89,10 @@ def __init__(self, repo_path: str, trust_boundary: TrustBoundary = TrustBoundary |
88 | 89 |
|
89 | 90 | git_available = False |
90 | 91 | try: |
91 | | - subprocess.run(["git", "--version"], capture_output=True, check=True) # nosec B603 B607 |
92 | | - git_available = True |
| 92 | + git_path = shutil.which("git") |
| 93 | + if git_path: |
| 94 | + subprocess.run([git_path, "--version"], capture_output=True, check=True) # nosec B603 B607 |
| 95 | + git_available = True |
93 | 96 | except (subprocess.CalledProcessError, FileNotFoundError): |
94 | 97 | pass |
95 | 98 |
|
@@ -130,7 +133,9 @@ def reconcile_untracked(self): |
130 | 133 | recovered = False |
131 | 134 | for f in disk_files: |
132 | 135 | if isinstance(self.audit, GitAuditProvider): |
133 | | - res = subprocess.run(["git", "ls-files", "--error-unmatch", f], |
| 136 | + git_path = shutil.which("git") |
| 137 | + if not git_path: continue |
| 138 | + res = subprocess.run([git_path, "ls-files", "--error-unmatch", f], |
134 | 139 | cwd=self.repo_path, capture_output=True) # nosec B603 B607 |
135 | 140 | if res.returncode != 0: |
136 | 141 | logger.info(f"Recovering untracked file: {f}") |
|
0 commit comments