check_no_game_data: exit 2 when git cannot list the files (CHECK-NO-GAME-DATA-GIT-ERROR) #922

Manually merged
github merged 2 commits from gh-pr/922/head into gh-pr/922/base 2026-11-26 09:28:23 +00:00
Owner

@⁠TuroYT on GitHub · 2026-11-24 15:12 UTC · original
TuroYT:fix/check-no-game-data-git-error → main · +49 −4 · 2 files · 2 commits · merged 2026-11-24 20:04 UTC

Claimed in the coordination issue as: CHECK-NO-GAME-DATA-GIT-ERROR (#14)

What was wrong

tracked_files in scripts/check_no_game_data.py (line 256, called from main) runs git ls-files -z with check=True and no handler. Two cases end in a traceback and exit status 1:

  • Run outside a git work tree: CalledProcessError ... status 128.
  • Run with git missing from PATH: FileNotFoundError: [Errno 2] No such file or directory: 'git'.

The docstring says exit 1 means game data was found, so a caller cannot tell the two apart. Only the unreadable-file path returns 2.

Reproduced on the branch before the change:

$ cd <empty temp dir>; python3 -I .../scripts/check_no_game_data.py
  ... subprocess.CalledProcessError: Command '['git', 'ls-files', '-z']' returned non-zero exit status 128.
rc=1
$ env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py
  ... FileNotFoundError: [Errno 2] No such file or directory: 'git'
rc=1

What changed

  • main catches OSError and CalledProcessError around the default-mode git call and returns 2.
  • It prints one line to stderr: check_no_game_data: cannot list the tracked files with git: <reason>. The reason is the first non-empty line git printed, or the OS error text.
  • The docstring documents exit 2.
  • The explicit-path mode and the normal in-repository output are unchanged.
  • tests/test_check_no_game_data.py: two tests. One empties PATH and runs in a plain folder. The other sets GIT_CEILING_DIRECTORIES and LC_ALL=C and runs in a folder outside any repository. Both expect exit 2, no stdout, one stderr line, and no traceback.

Tested

  • python3 -I tests/test_check_no_game_data.py: Ran 11 tests, OK (on the fixed code).
  • On the origin/main script: the two new tests fail (FAILED (failures=2)), so they catch the defect.
  • Normal repository output: python3 -I scripts/check_no_game_data.py > out.txt on the origin/main copy and on the fixed script gives identical bytes, exit 0 for both.
  • env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py with a file argument: exit 0 (no git call is made).
  • env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py: one line, exit 2.
  • Outside a repository: one line naming git, exit 2.
  • python3 -m compileall -q scripts tests: OK.
  • python3 -I tests/test_text_write_line_endings.py: OK, 3 tests.
  • python3 -I tests/test_no_game_data_workflow.py: OK, 3 tests.
  • python3 -I scripts/check_no_game_data.py scripts/check_no_game_data.py tests/test_check_no_game_data.py: exit 0.
  • python3 -I scripts/check_no_game_data.py over the whole tracked tree: exit 0.
  • git diff --check: clean.

Not tested: a real git failure with a multi-line message (for example, detected dubious ownership), a non-UTF-8 git message beyond a quick unit check of the helper, Windows, and macOS.

Not tested

  • Windows and macOS. The test runs only on the platform where it is executed.
  • The "game data found" exit 1 path on a repository with a real match, compared byte for byte with origin/main. The existing default-mode test covers exit 1 on the fixed code.

AI-assisted (Claude Code).

**@⁠TuroYT** on GitHub · 2026-11-24 15:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/922) `TuroYT:fix/check-no-game-data-git-error` → `main` · +49 −4 · 2 files · 2 commits · merged 2026-11-24 20:04 UTC Claimed in the coordination issue as: CHECK-NO-GAME-DATA-GIT-ERROR (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ## What was wrong `tracked_files` in `scripts/check_no_game_data.py` (line 256, called from `main`) runs `git ls-files -z` with `check=True` and no handler. Two cases end in a traceback and exit status 1: - Run outside a git work tree: `CalledProcessError ... status 128`. - Run with git missing from PATH: `FileNotFoundError: [Errno 2] No such file or directory: 'git'`. The docstring says exit 1 means game data was found, so a caller cannot tell the two apart. Only the unreadable-file path returns 2. Reproduced on the branch before the change: ``` $ cd <empty temp dir>; python3 -I .../scripts/check_no_game_data.py ... subprocess.CalledProcessError: Command '['git', 'ls-files', '-z']' returned non-zero exit status 128. rc=1 $ env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py ... FileNotFoundError: [Errno 2] No such file or directory: 'git' rc=1 ``` ## What changed - `main` catches `OSError` and `CalledProcessError` around the default-mode git call and returns 2. - It prints one line to stderr: `check_no_game_data: cannot list the tracked files with git: <reason>`. The reason is the first non-empty line git printed, or the OS error text. - The docstring documents exit 2. - The explicit-path mode and the normal in-repository output are unchanged. - `tests/test_check_no_game_data.py`: two tests. One empties PATH and runs in a plain folder. The other sets `GIT_CEILING_DIRECTORIES` and `LC_ALL=C` and runs in a folder outside any repository. Both expect exit 2, no stdout, one stderr line, and no traceback. ## Tested - `python3 -I tests/test_check_no_game_data.py`: Ran 11 tests, OK (on the fixed code). - On the origin/main script: the two new tests fail (`FAILED (failures=2)`), so they catch the defect. - Normal repository output: `python3 -I scripts/check_no_game_data.py > out.txt` on the origin/main copy and on the fixed script gives identical bytes, exit 0 for both. - `env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py` with a file argument: exit 0 (no git call is made). - `env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py`: one line, exit 2. - Outside a repository: one line naming git, exit 2. - `python3 -m compileall -q scripts tests`: OK. - `python3 -I tests/test_text_write_line_endings.py`: OK, 3 tests. - `python3 -I tests/test_no_game_data_workflow.py`: OK, 3 tests. - `python3 -I scripts/check_no_game_data.py scripts/check_no_game_data.py tests/test_check_no_game_data.py`: exit 0. - `python3 -I scripts/check_no_game_data.py` over the whole tracked tree: exit 0. - `git diff --check`: clean. Not tested: a real git failure with a multi-line message (for example, `detected dubious ownership`), a non-UTF-8 git message beyond a quick unit check of the helper, Windows, and macOS. ## Not tested - Windows and macOS. The test runs only on the platform where it is executed. - The "game data found" exit 1 path on a repository with a real match, compared byte for byte with origin/main. The existing default-mode test covers exit 1 on the fixed code. AI-assisted (Claude Code).
Outside a repository, or with git missing from PATH, the default mode died with a traceback and exit 1,
which is the "game data found" code. It now prints one line naming git and the error, and exits 2.
Tests cover a missing git, a folder outside any repository, and the unchanged results inside a repository.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:28:22 +00:00
github manually merged commit ec0d003e52 into gh-pr/922/base 2026-11-26 09:28:23 +00:00
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-24 16:14 UTC · original

Independent test of #922 (CHECK-NO-GAME-DATA-GIT-ERROR)

Head tested: 074e53069f (merge base a2892784). Environment: Windows 11, native Python 3.13.13, Git for Windows, no GPU. This covers the Windows run that the PR lists as not tested.

Commands and results:

  • python -I -B tests/test_check_no_game_data.py: Ran 11 tests, OK.
  • python -I -B tests/test_no_game_data_workflow.py: OK.
  • Same test file with scripts/check_no_game_data.py from the merge base: both new tests FAIL (FAILED (failures=2)).
  • Mutation: narrowed the new except to subprocess.CalledProcessError only. test_git_missing_is_one_stderr_line_and_exit_2 FAILS, so the OSError branch is covered too. Restored afterwards.
  • Manual run outside any repository: python -I scripts/check_no_game_data.py prints one line, check_no_game_data: cannot list the tracked files with git: fatal: not a git repository (or any of the parent directories): .git, and exits 2.
  • Manual run inside the worktree over the whole tracked tree: exit 0.
  • git merge-tree --write-tree origin/main <head> (origin/main 0af7753c): clean.
  • python -I scripts/check_no_game_data.py on the changed files: exit 0. git diff --check: clean.

Findings:

  • scripts/check_no_game_data.py:296-304: only the default (git) mode changes, and explicit paths never call git. tracked_files already uses capture_output=True (line 257), so git's message lands in e.stderr and is not also printed raw. That is why the output is exactly one line.
  • The only caller in the repository, .github/workflows/no-game-data.yml:35, treats any non-zero code as a failure, so exit 2 changes nothing there.
  • Minor, not blocking: the outside-repository test asserts the English not a git repository text via LC_ALL=C, which is fine on Windows and Linux. However, a GIT_DIR or GIT_WORK_TREE already set in the caller's environment would let git find a repository. Popping those from env would make the test fully hermetic.

Verdict: looks good.

AI-assisted.

**@⁠kawaii-shakal** on GitHub · 2026-11-24 16:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/922#issuecomment-7137332380) Independent test of #922 (CHECK-NO-GAME-DATA-GIT-ERROR) Head tested: 074e53069faa592b9fcabc47f128a383dcdc0f82 (merge base a2892784). Environment: Windows 11, native Python 3.13.13, Git for Windows, no GPU. This covers the Windows run that the PR lists as not tested. Commands and results: - `python -I -B tests/test_check_no_game_data.py`: Ran 11 tests, OK. - `python -I -B tests/test_no_game_data_workflow.py`: OK. - Same test file with `scripts/check_no_game_data.py` from the merge base: both new tests FAIL (`FAILED (failures=2)`). - Mutation: narrowed the new `except` to `subprocess.CalledProcessError` only. `test_git_missing_is_one_stderr_line_and_exit_2` FAILS, so the `OSError` branch is covered too. Restored afterwards. - Manual run outside any repository: `python -I scripts/check_no_game_data.py` prints one line, `check_no_game_data: cannot list the tracked files with git: fatal: not a git repository (or any of the parent directories): .git`, and exits 2. - Manual run inside the worktree over the whole tracked tree: exit 0. - `git merge-tree --write-tree origin/main <head>` (origin/main 0af7753c): clean. - `python -I scripts/check_no_game_data.py` on the changed files: exit 0. `git diff --check`: clean. Findings: - scripts/check_no_game_data.py:296-304: only the default (git) mode changes, and explicit paths never call git. `tracked_files` already uses `capture_output=True` (line 257), so git's message lands in `e.stderr` and is not also printed raw. That is why the output is exactly one line. - The only caller in the repository, `.github/workflows/no-game-data.yml:35`, treats any non-zero code as a failure, so exit 2 changes nothing there. - Minor, not blocking: the outside-repository test asserts the English `not a git repository` text via `LC_ALL=C`, which is fine on Windows and Linux. However, a `GIT_DIR` or `GIT_WORK_TREE` already set in the caller's environment would let git find a repository. Popping those from `env` would make the test fully hermetic. Verdict: looks good. AI-assisted.
Author
Owner

@⁠TuroYT on GitHub · 2026-11-24 17:05 UTC · original

Thanks for the Windows run and the mutation check.

Pushed ec0d003e5: test_outside_a_repository_is_one_stderr_line_and_exit_2 now builds its environment without GIT_DIR, GIT_WORK_TREE and GIT_INDEX_FILE. The test file passes (11 tests) with and without GIT_DIR set in the caller's environment.

Setting GIT_DIR also showed that the tests that create their own repositories (git add in a temporary directory) are not hermetic either: with GIT_DIR exported, they stage files into the repository that GIT_DIR points at. That is older than this PR and I left it alone here.

**@⁠TuroYT** on GitHub · 2026-11-24 17:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/922#issuecomment-7138665776) Thanks for the Windows run and the mutation check. Pushed ec0d003e5: `test_outside_a_repository_is_one_stderr_line_and_exit_2` now builds its environment without `GIT_DIR`, `GIT_WORK_TREE` and `GIT_INDEX_FILE`. The test file passes (11 tests) with and without `GIT_DIR` set in the caller's environment. Setting `GIT_DIR` also showed that the tests that create their own repositories (`git add` in a temporary directory) are not hermetic either: with `GIT_DIR` exported, they stage files into the repository that `GIT_DIR` points at. That is older than this PR and I left it alone here.
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-24 17:39 UTC · original · approved these changes

LGTM. Measured on Windows 11 (French locale), Python 3.14, against main cf4c00cba:

  • python -I tests/test_check_no_game_data.py: main Ran 9, OK; this PR and a local merge into main Ran 11, OK. With main's script, both new tests fail.
  • Outside a repository (GIT_CEILING_DIRECTORIES set), main prints a traceback and exits 1, and this PR prints one line and exits 2. The same holds with git removed from PATH.
  • On a French Windows, the git-missing line carries the OS error text (e.strerror), so it is localized. It is still one line with exit 2, which is all the test checks.

AI-assisted: yes (Claude Code ran the checks; I read them).

**@⁠MoonEyes** on GitHub · 2026-11-24 17:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/922#pullrequestreview-6044346114) · **approved these changes** LGTM. Measured on Windows 11 (French locale), Python 3.14, against main cf4c00cba: - `python -I tests/test_check_no_game_data.py`: main `Ran 9, OK`; this PR and a local merge into main `Ran 11, OK`. With main's script, both new tests fail. - Outside a repository (`GIT_CEILING_DIRECTORIES` set), main prints a traceback and exits 1, and this PR prints one line and exits 2. The same holds with git removed from PATH. - On a French Windows, the git-missing line carries the OS error text (`e.strerror`), so it is localized. It is still one line with exit 2, which is all the test checks. AI-assisted: yes (Claude Code ran the checks; I read them).
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 20:04 UTC · original

Merging.

Why merged: CHECK-NO-GAME-DATA-GIT-ERROR: check_no_game_data exits 2 with one stderr line when git can't list the tracked files. Exit 1 still means game data was found, so a broken git can no longer look like a clean scan or a hit. The scan logic itself is unchanged. kawaii-shakal checked it, and MoonEyes approved after the follow-up push, which only clears GIT_DIR in a test.

Why it's good: Own tests: 11 passed. The consistency set with its 2 new tests: 573 passed.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 6293c1c4f. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 571 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-24 20:04 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/922#issuecomment-7143014439) Merging. **Why merged:** CHECK-NO-GAME-DATA-GIT-ERROR: check_no_game_data exits 2 with one stderr line when git can't list the tracked files. Exit 1 still means game data was found, so a broken git can no longer look like a clean scan or a hit. The scan logic itself is unchanged. kawaii-shakal checked it, and MoonEyes approved after the follow-up push, which only clears GIT_DIR in a test. **Why it's good:** Own tests: 11 passed. The consistency set with its 2 new tests: 573 passed. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 6293c1c4f. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 571 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.