fix(conventions): check the whole repository when run from a subdirectory #4368

Merged
SandstromPL merged 1 commit from upstream-pr/4368 into main 2026-10-12 18:21:13 +00:00
SandstromPL commented 2026-10-12 07:51:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-12T07:51:43Z.


What

Two git calls in tools/check_conventions.py resolve paths against the current directory. Run from anywhere but the repository root, for example from tools/ or from a build folder as python3 ../tools/check_conventions.py, the checker gives wrong results without any warning:

  • git ls-tree -rz <head> lists only the current directory's subtree, with paths relative to it. From tools/, self.tree holds 30 paths instead of the whole tree. As a result:
    • every relative link in a changed document is reported as a doc-link error;
    • the checker finds no docs/dev/TechnicalDebt.md, so stubs already listed there are reported as silent-stub;
    • the submodule checks in repository() see no submodules, so a 3rdparty/ submodule without a .gitmodules url passes, and one outside 3rdparty/ crashes the check.
  • git grep … -- core/libs/prx searches <cwd>/core/libs/prx. From a subdirectory it finds nothing, so a real duplicate-export passes.

ls-tree now gets --full-tree. The grep gets --full-name and the pathspec :(top)core/libs/prx, so it searches from the top of the repository and prints root-relative paths, which is what duplicates() parses. With default configuration, the other git calls (diff, show <rev>:<path>, log, config --blob) already work from any directory. CI runs from the repository root, where the output does not change.

Tested

Ubuntu 24.04, Python 3.12.3, git 2.43:

  • All 15 tools/tests files pass, including 32 tests in test_check_conventions_comments.py. The new test_checks_from_a_subdirectory_see_the_whole_repository commits two libraries that define the same export, plus a document that links into core/, and runs the check from tools/. It expects only the duplicate-export finding. With main's checker the test fails: it reports a false doc-link and misses the duplicate.
  • Replay over the last 40 first-parent commits of main (--base <c>^1 --head <c>):
    • With main's checker, 13 of them give different output from tools/ than from the root.
    • With this change, the output from tools/ matches the root for all 40.
    • From the root, the output equals main's checker for all 40.
  • Two older commits show the errors that are missed. With this change, both match the root from tools/:
    • 0f6205aa3 (#153): from the root, main's checker reports 5 duplicate-export errors; from tools/ it reports none of them.
    • 6731a610e (#3470, the stray 3rdparty/imgui gitlink): the root reports the system-dependency error. From tools/, main's checker reports a false doc-link and a false silent-stub instead.
  • tools/check_conventions.py from main passes with this title and body.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Claude Code); I reviewed and tested every line

Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4826478840 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4368). Originally posted by [SandstromPL](https://github.com/SandstromPL) on 2026-10-12T07:51:43Z. --- ### What Two git calls in `tools/check_conventions.py` resolve paths against the current directory. Run from anywhere but the repository root, for example from `tools/` or from a build folder as `python3 ../tools/check_conventions.py`, the checker gives wrong results without any warning: - `git ls-tree -rz <head>` lists only the current directory's subtree, with paths relative to it. From `tools/`, `self.tree` holds 30 paths instead of the whole tree. As a result: - every relative link in a changed document is reported as a `doc-link` error; - the checker finds no `docs/dev/TechnicalDebt.md`, so stubs already listed there are reported as `silent-stub`; - the submodule checks in `repository()` see no submodules, so a `3rdparty/` submodule without a `.gitmodules` url passes, and one outside `3rdparty/` crashes the check. - `git grep … -- core/libs/prx` searches `<cwd>/core/libs/prx`. From a subdirectory it finds nothing, so a real `duplicate-export` passes. `ls-tree` now gets `--full-tree`. The grep gets `--full-name` and the pathspec `:(top)core/libs/prx`, so it searches from the top of the repository and prints root-relative paths, which is what `duplicates()` parses. With default configuration, the other git calls (`diff`, `show <rev>:<path>`, `log`, `config --blob`) already work from any directory. CI runs from the repository root, where the output does not change. ### Tested Ubuntu 24.04, Python 3.12.3, git 2.43: - All 15 `tools/tests` files pass, including 32 tests in `test_check_conventions_comments.py`. The new `test_checks_from_a_subdirectory_see_the_whole_repository` commits two libraries that define the same export, plus a document that links into `core/`, and runs the check from `tools/`. It expects only the `duplicate-export` finding. With main's checker the test fails: it reports a false `doc-link` and misses the duplicate. - Replay over the last 40 first-parent commits of main (`--base <c>^1 --head <c>`): - With main's checker, 13 of them give different output from `tools/` than from the root. - With this change, the output from `tools/` matches the root for all 40. - From the root, the output equals main's checker for all 40. - Two older commits show the errors that are missed. With this change, both match the root from `tools/`: - `0f6205aa3` (#153): from the root, main's checker reports 5 `duplicate-export` errors; from `tools/` it reports none of them. - `6731a610e` (#3470, the stray `3rdparty/imgui` gitlink): the root reports the `system-dependency` error. From `tools/`, main's checker reports a false `doc-link` and a false `silent-stub` instead. - `tools/check_conventions.py` from main passes with this title and body. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes (Claude Code); I reviewed and tested every line Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-12 07:53:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T07:53:39Z.


I ran python3 tools/tests/test_check_conventions_comments.py on PR head 872c3ba6 in the Linux workspace. All 32 tests passed, including the new subdirectory regression case. This was the focused test file only; I did not rerun the broader tools suite.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120083096 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4368#issuecomment-6120083096). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T07:53:39Z. --- I ran `python3 tools/tests/test_check_conventions_comments.py` on PR head `872c3ba6` in the Linux workspace. All 32 tests passed, including the new subdirectory regression case. This was the focused test file only; I did not rerun the broader tools suite.
SandstromPL commented 2026-10-12 07:56:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-12T07:56:42Z.


Thanks for checking. For completeness: all 15 tools/tests files pass on 872c3ba6 here as well (Ubuntu 24.04, Python 3.12.3), as listed under Tested.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120124333 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4368#issuecomment-6120124333). Originally posted by [SandstromPL](https://github.com/SandstromPL) on 2026-10-12T07:56:42Z. --- Thanks for checking. For completeness: all 15 `tools/tests` files pass on `872c3ba6` here as well (Ubuntu 24.04, Python 3.12.3), as listed under Tested.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4368
No description provided.