Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
SandstromPL:fix/conventions-run-from-subdirectory
Oct 12, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
SandstromPL:fix/conventions-run-from-subdirectory

Conversation

@SandstromPL

@SandstromPL SandstromPL commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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/:
  • 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

…tory

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MarcZX10

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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.

@oneandonlydean oneandonlydean self-assigned this Oct 12, 2026
@oneandonlydean
oneandonlydean merged commit 59a2167 into boykopovar:main Oct 12, 2026
15 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.

3 participants