Skip to content

check_no_game_data: a run from a subfolder checks the whole repository, not only that subtree - #8231

Closed
Crxckyi wants to merge 1 commit into
ProjectLeonida:mainfrom
Crxckyi:nogamedata-subfolder
Closed

Crxckyi wants to merge 1 commit into
ProjectLeonida:mainfrom
Crxckyi:nogamedata-subfolder

Conversation

@Crxckyi

@Crxckyi Crxckyi commented Nov 23, 2026

Copy link
Copy Markdown

Claimed in the coordination issue as: #8047 (comment)

Depends on: none. #8090, #6396 and #6079 also edit scripts/check_no_game_data.py, but they rewrite the paths = argv or tracked_files(os.getcwd()) line in main(). This PR only changes the body of tracked_files(), so it should merge cleanly next to any of them.

What and why

With no arguments, check_no_game_data.py ran git ls-files -z in the current folder. Git lists only that subtree there, so a run from a subfolder skipped the rest of the repository and exited 0 even with game data elsewhere.

Repro (synthetic, no game files): a git repo with other/x.bin starting with DDS and sub/a.txt, both added.

  • from the top level: other\x.bin: DDS texture, exit 1 (correct)
  • from sub/: no output, exit 0 (before); ..\other\x.bin: DDS texture, exit 1 (after)

tracked_files() now asks git rev-parse --show-toplevel (newline stripped, normpath for the / separators on Windows), runs git ls-files -z from there and returns absolute paths, as before. Error handling is unchanged: outside a git checkout it still ends in the same CalledProcessError, now from rev-parse instead of ls-files (#8090 turns that into one error line).

New test test_default_mode_from_a_subfolder_checks_the_whole_repository: it fails on main (0 != 1) and passes with this change.

Tested

Windows 11, CPython 3.13.14, CPU only (no GPU or driver involved), on main dde82f27e:

  • python -I tests/test_check_no_game_data.py: 9 OK (8 on main, plus the new test).
  • python -I tests/test_no_game_data_workflow.py (3 OK), python -I tests/test_ci_registration.py (14 OK), python -m compileall -q scripts tests, git diff --check: pass.
  • python -I scripts/check_no_game_data.py from the top level and from scripts/: exit 0, and both list the same 2,273 tracked files.
  • tests/test_tool_stdout_encoding.py and tests/test_text_write_line_endings.py fail the same way on main; this change does not touch them.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

…ree, so a run from a subfolder checks the whole repository

The default mode ran `git ls-files` in the current folder, which lists only
that subtree: from `sub/`, a game file in `other/` passed with exit 0.
tracked_files() now asks `git rev-parse --show-toplevel` and lists from there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d9200bb708d5176a3525ba903f5ca364af17a7ae)

@devnull34 devnull34 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified via Tier 2 Free Cloud (Groq gpt-oss-120b) & local test execution: Asking git rev-parse --show-toplevel in tracked_files() ensures running check_no_game_data from a subfolder inspects all tracked files across the entire worktree rather than omitting siblings in parallel directories. All 9 tests in test_check_no_game_data.py pass cleanly.

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Confirmed independently on Windows 11 (CPython 3.14.3).

Negative control on main

On main, running scripts/check_no_game_data.py with no arguments from a repository subfolder (cwd=sub/) executed git ls-files -z only within that subfolder. Tracked files in sibling directories were omitted from verification:

FAIL: test_default_mode_from_a_subfolder_checks_the_whole_repository (CheckNoGameData)
AssertionError: 0 != 1 : 

The scan exited 0 with empty stdout despite a committed DDS texture residing in other/x.bin.

Verification with PR #8231

  • tracked_files() discovers the work tree root via git rev-parse --show-toplevel, normalizes the path across platforms (os.path.normpath), and runs git ls-files -z with cwd=top.
  • CheckNoGameData.test_default_mode_from_a_subfolder_checks_the_whole_repository passes, detecting other/x.bin and exiting 1.
  • All 9 tests in tests/test_check_no_game_data.py, 3 tests in tests/test_no_game_data_workflow.py, and 14 tests in tests/test_ci_registration.py pass.
  • python -m compileall and python -I scripts/check_no_game_data.py pass cleanly.

LGTM.

(Review conducted with AI assistance)

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 3abcc2a5 on Windows 11 (Python 3.14.7, CPU-only, no game files): pass.

Test Suite Execution

  • python -I tests/test_check_no_game_data.py -v: 9/9 passed (7.83s).
    • New test test_default_mode_from_a_subfolder_checks_the_whole_repository: passed.
  • Related suites: python -I tests/test_no_game_data_workflow.py (3/3 passed) and python -I tests/test_ci_registration.py (14/14 passed).

Negative Control

  • Reverting scripts/check_no_game_data.py to origin/main (dde82f27e):
    • 8 passed, 1 failed: test_default_mode_from_a_subfolder_checks_the_whole_repository.
    • Failure mode: AssertionError: 0 != 1 : . Running check_no_game_data.py without arguments from a subfolder (cwd=.../sub) on origin/main ran git ls-files -z relative to sub/, skipping the repository top-level and other directories (e.g. other/x.bin: DDS texture), exiting 0 instead of 1.
  • Restoring scripts/check_no_game_data.py from the PR branch: tracked_files() discovers top-level root via git rev-parse --show-toplevel and normalizes path separators, successfully detecting game data outside the current subfolder and returning exit 1.

Hygiene

  • python -m compileall -q scripts/check_no_game_data.py tests/test_check_no_game_data.py: clean.
  • python -I scripts/check_no_game_data.py scripts/check_no_game_data.py tests/test_check_no_game_data.py: clean (synthetic test repo/fixtures only).
  • git diff --check origin/main: clean.
  • Line endings: strict LF preserved across both modified files.

AI-assisted review.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 3abcc2a5 on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_check_no_game_data.py -> OK

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@rideinstead

Copy link
Copy Markdown

✅ Automated security review: CLEAN (commit 3abcc2a5)

  • No findings.

Scope: static analysis of added diff lines only; no code was executed. Please review findings manually.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested 3abcc2a5 on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main 867d922f: pass

  • python -I tests/test_check_no_game_data.py: Ran 9 tests, OK. With only the non-test files reverted to main: FAILED (failures=1).
  • compileall and scripts/check_no_game_data.py on the changed files: clean.

For whoever merges: this composes with our open #8090, which turns the default-mode call outside a checkout into one error line; the merge is clean in either order, and #8090 first keeps the new git invocation's failure path one line.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting.

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.

7 participants