Walk up from CWD to find the directory containing .git.
()
| 50 | |
| 51 | |
| 52 | def find_repo_root() -> Path: |
| 53 | """Walk up from CWD to find the directory containing .git.""" |
| 54 | path = Path.cwd() |
| 55 | while path != path.parent: |
| 56 | if (path / ".git").exists(): |
| 57 | return path |
| 58 | path = path.parent |
| 59 | return Path.cwd() |
| 60 | |
| 61 | |
| 62 | # --------------------------------------------------------------------------- |