Check git working tree status and warn if dirty.
()
| 222 | |
| 223 | |
| 224 | def _check_git_working_tree() -> None: |
| 225 | """Check git working tree status and warn if dirty.""" |
| 226 | try: |
| 227 | dirty = ( |
| 228 | subprocess.check_output(["git", "status", "--porcelain"], stderr=subprocess.DEVNULL) |
| 229 | .decode() |
| 230 | .strip() |
| 231 | ) |
| 232 | if dirty: |
| 233 | print("⚠️ Warning: Git working tree has uncommitted changes:") |
| 234 | for line in dirty.splitlines()[:10]: |
| 235 | print(f" {line}") |
| 236 | if len(dirty.splitlines()) > 10: |
| 237 | print(f" ... and {len(dirty.splitlines()) - 10} more files") |
| 238 | print() |
| 239 | except subprocess.CalledProcessError: |
| 240 | pass |
| 241 | |
| 242 | |
| 243 | # ============================================================================ |
no outgoing calls
no test coverage detected