源码: prompt.rs:265-275
(cwd: Path, args: list[str])
| 210 | |
| 211 | |
| 212 | def _read_git_output(cwd: Path, args: list[str]) -> Optional[str]: |
| 213 | """源码: prompt.rs:265-275""" |
| 214 | try: |
| 215 | result = subprocess.run( |
| 216 | ["git"] + args, cwd=cwd, capture_output=True, text=True, timeout=10, |
| 217 | ) |
| 218 | except (FileNotFoundError, subprocess.TimeoutExpired): |
| 219 | return None |
| 220 | if result.returncode != 0: |
| 221 | return None |
| 222 | return result.stdout |
| 223 | |
| 224 | |
| 225 | # ============================================================ |