Skip to content

refactor(scripts): find the repo root by pyproject.toml instead of .git - #170

Merged
dengqiaoyu merged 1 commit into
apple:mainfrom
dengqiaoyu:find-repo-root-pyproject
Oct 28, 2026
Merged

dengqiaoyu merged 1 commit into
apple:mainfrom
dengqiaoyu:find-repo-root-pyproject

Conversation

@dengqiaoyu

Copy link
Copy Markdown
Contributor

scripts._utils.find_repo_root walked up to the nearest .git, so tooling that calls it failed in a source tree without git metadata, such as an unpacked archive. It now walks up to the nearest pyproject.toml, requires the caller to pass a start path, and accepts a marker override.

The remaining callers of coreai_opt._utils.repo_utils.find_repo_root move to the same rule, so nothing in ci/, docs/, or tests/ uses it anymore; a follow-up removes it.

`scripts._utils.find_repo_root` walked up to the nearest `.git`, so it failed in source trees without git metadata, such as an unpacked archive. It now walks up to the nearest `pyproject.toml`, requires an explicit start path, and accepts a `marker` override.

- Move the remaining `coreai_opt._utils.repo_utils` callers to the helper (tests, `ci/nox/utils.py`) or, where the repo is not importable yet, to an inline stdlib walk (`ci/nox/noxfile.py`).
- Replace fixed `parents[N]` depths in the devtools tests with the helper.
- Anchor `docs/scripts/generate_api_index.py` on the working directory, which is the repo whose index it writes.
- Add `pythonpath = ["."]` to the pytest config so tests outside the `tests` package can import `scripts.*`.
- Add tests for `find_repo_root`.
Comment thread ci/nox/noxfile.py Resolved
@dengqiaoyu
dengqiaoyu merged commit 54390fe into apple:main Oct 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants