()
| 49 | |
| 50 | |
| 51 | def get_root() -> str: |
| 52 | # Git 2.25 introduced a change to "rev-parse --show-toplevel" that exposed |
| 53 | # underlying volumes for Windows drives mapped with SUBST. We use |
| 54 | # "rev-parse --show-cdup" to get the appropriate path, but must perform |
| 55 | # an extra check to see if we are in the .git directory. |
| 56 | try: |
| 57 | root = os.path.abspath( |
| 58 | cmd_output('git', 'rev-parse', '--show-cdup')[1].strip(), |
| 59 | ) |
| 60 | inside_git_dir = cmd_output( |
| 61 | 'git', 'rev-parse', '--is-inside-git-dir', |
| 62 | )[1].strip() |
| 63 | except CalledProcessError: |
| 64 | raise FatalError( |
| 65 | 'git failed. Is it installed, and are you in a Git repository ' |
| 66 | 'directory?', |
| 67 | ) |
| 68 | if inside_git_dir != 'false': |
| 69 | raise FatalError( |
| 70 | 'git toplevel unexpectedly empty! make sure you are not ' |
| 71 | 'inside the `.git` directory of your repository.', |
| 72 | ) |
| 73 | return root |
| 74 | |
| 75 | |
| 76 | def get_git_dir(git_root: str = '.') -> str: |
no test coverage detected