|
1 | 1 | """Repository path helpers for PureAutoCodeQL. |
2 | 2 |
|
3 | 3 | Use these instead of hand-counting ``Path(__file__).parent`` hops when |
4 | | -resolving assets that live at the repository root (prompts/, tools/, |
5 | | -resources/, projects/, config/). Nested packages under |
| 4 | +resolving assets that live at the repository root (``prompts/``, ``tools/``, |
| 5 | +``resources/``, ``projects/``, ``config/``). Nested packages under |
6 | 6 | ``pure_auto_codeql/`` make relative parent walks brittle. |
7 | 7 | """ |
8 | 8 |
|
|
11 | 11 | from functools import lru_cache |
12 | 12 | from pathlib import Path |
13 | 13 |
|
14 | | -_MARKERS = ("pyproject.toml",) |
15 | | - |
16 | 14 |
|
17 | 15 | def _looks_like_repo_root(path: Path) -> bool: |
18 | | - if not (path / "pyproject.toml").is_file(): |
19 | | - return False |
20 | | - # Prefer a root that still has the runtime asset layout used in-repo. |
21 | | - if (path / "prompts").is_dir() or (path / "tools").is_dir(): |
22 | | - return True |
23 | | - return True |
| 16 | + """True when *path* is the PureAutoCodeQL checkout root.""" |
| 17 | + return (path / "pyproject.toml").is_file() |
24 | 18 |
|
25 | 19 |
|
26 | 20 | @lru_cache(maxsize=1) |
27 | 21 | def get_repo_root() -> Path: |
28 | 22 | """Return the repository root directory. |
29 | 23 |
|
30 | 24 | Walks upward from this file until a directory containing |
31 | | - ``pyproject.toml`` is found. Falls back to three parents above this |
32 | | - module (``pure_auto_codeql/paths.py`` → repo root in the normal |
33 | | - checkout layout) if markers are missing (e.g. unusual install). |
| 25 | + ``pyproject.toml`` is found. Falls back to the parent of the |
| 26 | + ``pure_auto_codeql`` package (normal checkout layout) if no marker is |
| 27 | + found (e.g. unusual install layout). |
34 | 28 | """ |
35 | 29 | start = Path(__file__).resolve().parent |
36 | 30 | for candidate in (start, *start.parents): |
|
0 commit comments