upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorQemmHD <stephenlethco2@gmail.com>2026-11-24 15:04:57 -0500
committerGitHub <noreply@github.com>2026-11-24 15:04:57 -0500
commit85e472df8d9d43298059934d0ffe33ea4f113377 (patch)
tree286cb57b2cc0ac161a56465f54839f4df026699b /scripts
parent842b56c004faf2b66db769e6702ae50893fcd759 (diff)
parentec0d003e5279099945afad1eb9764aa8dec89349 (diff)
Merge pull request #922 from TuroYT/fix/check-no-game-data-git-error
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).
Diffstat (limited to 'scripts')
-rw-r--r--scripts/check_no_game_data.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/scripts/check_no_game_data.py b/scripts/check_no_game_data.py
index a5b65e242..bccee5e68 100644
--- a/scripts/check_no_game_data.py
+++ b/scripts/check_no_game_data.py
@@ -21,7 +21,8 @@ under a budget per checked file (64 MiB expanded, 10,000 members), so a zip bomb
21reported as archives that can't be checked. 21reported as archives that can't be checked.
22 22
23Prints one line per match, `<path>: <format>` (`<format> in <archive> (<member>)` for a match inside an archive), and 23Prints one line per match, `<path>: <format>` (`<format> in <archive> (<member>)` for a match inside an archive), and
24exits 1 if there is any. Standard library only, no game files. 24exits 1 if there is any. It exits 2 when a file cannot be read or git cannot list the tracked files (outside a
25repository, or git not installed). Standard library only, no game files.
25""" 26"""
26import bz2 27import bz2
27import gzip 28import gzip
@@ -257,6 +258,14 @@ def tracked_files(root):
257 return [os.path.join(root, p) for p in out.decode("utf-8", "surrogateescape").split("\0") if p] 258 return [os.path.join(root, p) for p in out.decode("utf-8", "surrogateescape").split("\0") if p]
258 259
259 260
261def git_error(e):
262 """One line on why git could not list the files: the first line git printed, or the OS error."""
263 if isinstance(e, subprocess.CalledProcessError):
264 lines = (e.stderr or b"").decode("utf-8", "replace").splitlines()
265 return next((line.strip() for line in lines if line.strip()), f"exit status {e.returncode}")
266 return e.strerror or str(e)
267
268
260def check(paths, unreadable=None): 269def check(paths, unreadable=None):
261 """[(path, format)] for every regular file in `paths` that starts like game data. 270 """[(path, format)] for every regular file in `paths` that starts like game data.
262 271
@@ -285,7 +294,14 @@ def display(path):
285 294
286 295
287def main(argv): 296def main(argv):
288 paths = argv or tracked_files(os.getcwd()) 297 if argv:
298 paths = argv
299 else:
300 try:
301 paths = tracked_files(os.getcwd())
302 except (OSError, subprocess.CalledProcessError) as e:
303 print(f"check_no_game_data: cannot list the tracked files with git: {git_error(e)}", file=sys.stderr)
304 return 2 # not 1: that is the 'game data found' code
289 unreadable = [] 305 unreadable = []
290 found = check(paths, unreadable) 306 found = check(paths, unreadable)
291 for path, name in found: 307 for path, name in found: