Check if git working directory is clean. Raises: SystemExit: If there are uncommitted changes.
()
| 143 | |
| 144 | |
| 145 | def check_git_clean() -> None: |
| 146 | """Check if git working directory is clean. |
| 147 | |
| 148 | Raises: |
| 149 | SystemExit: If there are uncommitted changes. |
| 150 | """ |
| 151 | try: |
| 152 | status = run_command(["git", "status", "--porcelain"]) |
| 153 | if status: |
| 154 | console.print( |
| 155 | "[red]Error:[/red] You have uncommitted changes. Please commit or stash them first." |
| 156 | ) |
| 157 | sys.exit(1) |
| 158 | except subprocess.CalledProcessError as e: |
| 159 | console.print(f"[red]Error checking git status:[/red] {e}") |
| 160 | sys.exit(1) |
| 161 | |
| 162 | |
| 163 | def _branch_exists_local(branch: str, cwd: Path | None = None) -> bool: |
no test coverage detected