scripts/carve_all.ps1: validate dirs, filter -File and publish coverage.json atomically #1847

Open
github-bot wants to merge 1 commit from github-bot/gh-1847 into main AGit
Owner

@⁠kirigayakazima on GitHub · 2026-11-25 13:01 UTC · original
kirigayakazima:fix/carve-all-safety → main · +72 −4 · 2 files · 1 commits · open

Claimed in the coordination issue as: CARVE-ALL-FILE-FILTER-EMPTY-AND-ATOMIC-COVERAGE (#1608)

What and why

  • Validate -Game as a directory (Test-Path -LiteralPath $Game -PathType Container) and ensure -Out is not an existing file before creating $outFull via [System.IO.Directory]::CreateDirectory(...) (literal path safe with [ ] characters).
  • Add -File to Get-ChildItem -LiteralPath $Game -Recurse -File -Filter *.rpf so directories named *.rpf are skipped rather than passed to tools/rpf9_carve.py.
  • Emit valid "[]" JSON when no .rpf archives are found, write coverage.json atomically via .coverage.<pid>.<guid>.tmp UTF-8 no-BOM staging + Move-Item -LiteralPath ... -Force + finally cleanup, and skip Format-Table when $rows.Count -eq 0.
  • Preserve CRLF line endings on scripts/carve_all.ps1 and add PowerShell 5.1 regression tests in tests/test_carve_all_paths.py.

Tested

  • python -I tests/test_carve_all_paths.py -v (live Windows PowerShell 5.1) -> Ran 11 tests in 11.463s, OK.
  • python -I tests/test_carve_all_brackets.py -v -> Ran 1 test in 0.461s, OK.
  • Detached upstream/main (98c2f777) baseline worktree with updated tests/test_carve_all_paths.py -> Ran 11 tests in 11.603s, FAILED (failures=2, errors=1).
  • CRLF verification on scripts/carve_all.ps1 -> PS1_CRLF=81 PS1_LF_ONLY=0.
  • python -I tests/test_ci_registration.py -> Ran 16 tests in 5.282s, OK.
  • python -I tests/test_text_write_line_endings.py -> Ran 3 tests in 12.773s, OK.
  • python -I scripts/check_no_game_data.py scripts/carve_all.ps1 tests/test_carve_all_paths.py, python -I -m compileall -q tests/test_carve_all_paths.py, and git diff --check -> exit 0.

GPUs tested: n/a (Windows PowerShell 5.1 + stdlib Python tests on Windows 11 x64)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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)
**@⁠kirigayakazima** on GitHub · 2026-11-25 13:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1847) `kirigayakazima:fix/carve-all-safety` → `main` · +72 −4 · 2 files · 1 commits · open Claimed in the coordination issue as: CARVE-ALL-FILE-FILTER-EMPTY-AND-ATOMIC-COVERAGE (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why - Validate `-Game` as a directory (`Test-Path -LiteralPath $Game -PathType Container`) and ensure `-Out` is not an existing file before creating `$outFull` via `[System.IO.Directory]::CreateDirectory(...)` (literal path safe with `[ ]` characters). - Add `-File` to `Get-ChildItem -LiteralPath $Game -Recurse -File -Filter *.rpf` so directories named `*.rpf` are skipped rather than passed to `tools/rpf9_carve.py`. - Emit valid `"[]"` JSON when no `.rpf` archives are found, write `coverage.json` atomically via `.coverage.<pid>.<guid>.tmp` UTF-8 no-BOM staging + `Move-Item -LiteralPath ... -Force` + `finally` cleanup, and skip `Format-Table` when `$rows.Count -eq 0`. - Preserve CRLF line endings on `scripts/carve_all.ps1` and add PowerShell 5.1 regression tests in `tests/test_carve_all_paths.py`. ### Tested - `python -I tests/test_carve_all_paths.py -v` (live Windows PowerShell 5.1) -> `Ran 11 tests in 11.463s`, `OK`. - `python -I tests/test_carve_all_brackets.py -v` -> `Ran 1 test in 0.461s`, `OK`. - Detached `upstream/main` (`98c2f777`) baseline worktree with updated `tests/test_carve_all_paths.py` -> `Ran 11 tests in 11.603s`, `FAILED (failures=2, errors=1)`. - CRLF verification on `scripts/carve_all.ps1` -> `PS1_CRLF=81 PS1_LF_ONLY=0`. - `python -I tests/test_ci_registration.py` -> `Ran 16 tests in 5.282s`, `OK`. - `python -I tests/test_text_write_line_endings.py` -> `Ran 3 tests in 12.773s`, `OK`. - `python -I scripts/check_no_game_data.py scripts/carve_all.ps1 tests/test_carve_all_paths.py`, `python -I -m compileall -q tests/test_carve_all_paths.py`, and `git diff --check` -> exit `0`. GPUs tested: n/a (Windows PowerShell 5.1 + stdlib Python tests on Windows 11 x64) AI-assisted: yes ### Checklist - [x] Based on current main and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:08:18 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1847/head:github-bot/gh-1847'
git switch 'github-bot/gh-1847'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1847'
git switch 'github-bot/gh-1847'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1847'
git switch 'github-bot/gh-1847'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1847'
git switch 'main'
git merge --squash 'github-bot/gh-1847'
git switch 'main'
git merge --ff-only 'github-bot/gh-1847'
git switch 'main'
git merge 'github-bot/gh-1847'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.