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

Closed
opened 2026-11-26 20:19:37 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/922
Author: @TuroYT
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: fix/check-no-game-data-git-error


📝 Commits (2)

  • 074e530 check_no_game_data: exit 2 when git cannot list the files (CHECK-NO-GAME-DATA-GIT-ERROR)
  • ec0d003 test_check_no_game_data: drop GIT_DIR, GIT_WORK_TREE and GIT_INDEX_FILE in the outside-a-repository test

📊 Changes

2 files changed (+49 additions, -4 deletions)

View changed files

📝 scripts/check_no_game_data.py (+18 -2)
📝 tests/test_check_no_game_data.py (+31 -2)

📄 Description

Claimed in the coordination issue as: CHECK-NO-GAME-DATA-GIT-ERROR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135522186)

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).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/922 **Author:** [@TuroYT](https://github.com/TuroYT) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `fix/check-no-game-data-git-error` --- ### 📝 Commits (2) - [`074e530`](https://github.com/ubiquitarianism/leonida/commit/074e53069faa592b9fcabc47f128a383dcdc0f82) check_no_game_data: exit 2 when git cannot list the files (CHECK-NO-GAME-DATA-GIT-ERROR) - [`ec0d003`](https://github.com/ubiquitarianism/leonida/commit/ec0d003e5279099945afad1eb9764aa8dec89349) test_check_no_game_data: drop GIT_DIR, GIT_WORK_TREE and GIT_INDEX_FILE in the outside-a-repository test ### 📊 Changes **2 files changed** (+49 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `scripts/check_no_game_data.py` (+18 -2) 📝 `tests/test_check_no_game_data.py` (+31 -2) </details> ### 📄 Description Claimed in the coordination issue as: CHECK-NO-GAME-DATA-GIT-ERROR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135522186) ## 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:37 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#960
No description provided.