Option C Tools
Loading...
Searching...
No Matches
project_root Namespace Reference

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

Detailed Description

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.

Function Documentation

◆ find_project_root()

Path project_root.find_project_root ( Path start)

Definition at line 28 of file project_root.py.

Here is the caller graph for this function:

◆ get_project_root()

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.

Here is the call graph for this function:

◆ is_within_project_root()

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.

Here is the caller graph for this function:

◆ validate_path_containment()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ MAX_OCTRC_SIZE

int project_root.MAX_OCTRC_SIZE = 64 * 1024

Definition at line 25 of file project_root.py.