|
Option C Tools
|
Functions | |
| Path | find_project_root (Path start) |
| Path | get_project_root (click.Context ctx) |
| bool | is_within_project_root (Path path, Path project_root) |
| Path | validate_path_containment (Path path, Path project_root, bool allow_outside=False) |
Variables | |
| int | MAX_OCTRC_SIZE = 64 * 1024 |
Purpose ------- Provide shared logic for detecting the root of an Option C project. Responsibilities ---------------- - Walk upward from the current directory. - Identify the project root by required directories.
| Path project_root.find_project_root | ( | Path | start | ) |
| Path project_root.get_project_root | ( | click.Context | ctx | ) |
Return project root from --root-dir override or auto-detection. When ``--root-dir`` is supplied, OI-405 requires the target directory to look like an Option C project (contain ``pyproject.toml`` or ``.octrc.json``). If the user intentionally wants to point at an unrelated directory, they must also pass ``--allow-outside-project``, which is recorded in ``ctx.obj``.
Definition at line 84 of file project_root.py.
| bool project_root.is_within_project_root | ( | Path | path, |
| Path | project_root ) |
Pure predicate: True if ``path`` resolves inside ``project_root``. Symlink-safe: both sides are resolved before comparison so symlink targets cannot escape the project root. Never raises — any ``OSError`` during resolution is treated as "not inside". Intended for library callers (e.g. ``oct.core.git``) that must not depend on Click.
Definition at line 116 of file project_root.py.
| Path project_root.validate_path_containment | ( | Path | path, |
| Path | project_root, | ||
| bool | allow_outside = False ) |
Resolve ``path`` and verify it is within ``project_root``. If ``allow_outside`` is True, the resolved path is returned without containment enforcement. Otherwise, a ``click.ClickException`` is raised when the path falls outside ``project_root``. Used by export and clean commands to prevent accidental operations on files outside the project via symlink tricks or bare ``..`` paths (OI-405).
Definition at line 136 of file project_root.py.
| int project_root.MAX_OCTRC_SIZE = 64 * 1024 |
Definition at line 25 of file project_root.py.