Absolute repo root for `cwd`, or None if not in a work tree.
(cwd)
| 142 | |
| 143 | |
| 144 | def _git_toplevel(cwd): |
| 145 | """Absolute repo root for `cwd`, or None if not in a work tree.""" |
| 146 | try: |
| 147 | r = subprocess.run( |
| 148 | [*GIT_CMD, "rev-parse", "--show-toplevel"], |
| 149 | cwd=cwd, capture_output=True, text=True, timeout=5, |
| 150 | ) |
| 151 | return r.stdout.strip() if r.returncode == 0 and r.stdout.strip() else None |
| 152 | except (subprocess.TimeoutExpired, FileNotFoundError, OSError): |
| 153 | return None |
| 154 | |
| 155 | |
| 156 | def _git_dir(repo_root): |
no outgoing calls
no test coverage detected