Quick check for uncommitted or diffed changes.
(root: Path, base: str)
| 14 | |
| 15 | |
| 16 | def _has_git_changes(root: Path, base: str) -> bool: |
| 17 | """Quick check for uncommitted or diffed changes.""" |
| 18 | try: |
| 19 | result = subprocess.run( |
| 20 | ["git", "diff", "--name-only", base, "--"], |
| 21 | capture_output=True, stdin=subprocess.DEVNULL, text=True, |
| 22 | cwd=str(root), timeout=10, |
| 23 | ) |
| 24 | if result.returncode == 0 and result.stdout.strip(): |
| 25 | return True |
| 26 | # Also check staged/unstaged |
| 27 | result2 = subprocess.run( |
| 28 | ["git", "status", "--porcelain"], |
| 29 | capture_output=True, stdin=subprocess.DEVNULL, text=True, |
| 30 | cwd=str(root), timeout=10, |
| 31 | ) |
| 32 | return bool(result2.stdout.strip()) |
| 33 | except (FileNotFoundError, subprocess.TimeoutExpired): |
| 34 | return False |
| 35 | |
| 36 | |
| 37 | def get_minimal_context( |
no outgoing calls
no test coverage detected