Find the git root directory.
()
| 116 | |
| 117 | @staticmethod |
| 118 | def _find_git_root() -> Path: |
| 119 | """Find the git root directory.""" |
| 120 | try: |
| 121 | result = subprocess.run( |
| 122 | ["git", "rev-parse", "--show-toplevel"], |
| 123 | capture_output=True, |
| 124 | text=True, |
| 125 | check=True |
| 126 | ) |
| 127 | return Path(result.stdout.strip()) |
| 128 | except subprocess.CalledProcessError: |
| 129 | print("Error: Not in a git repository") |
| 130 | sys.exit(1) |
| 131 | |
| 132 | def run_git(self, args: List[str], check: bool = True) -> subprocess.CompletedProcess: |
| 133 | """Run a git command.""" |