When a `patch_env()` body deletes a variable that was initially absent, cleanup raises `KeyError` and can mask an exception from the body. Use `os.environ.pop(name, None)` to restore absence idempotently while preserving restoration of existing values. Add 18 regression cases for absent, empty and populated original values, keep/replace/delete body mutations and normal/exceptional exits. The focused CLI-backend tests changed from 2 failed and 16 passed to 18 passed. Ruff lint/format and `git diff --check` passed. The full suite was not run because its required `GixPython` Windows wheel was unavailable. Agent-Model: unknown
1 task
Byron
added a commit
that referenced
this pull request
Nov 5, 2026
<!-- agent -->
Restore Windows CI coverage for `PathLike` revision arguments. The test
introduced in `6de90f1c` uses `Path("refs/heads/main")`, which emits
backslashes on Windows. Those are invalid Git reference names, so resolving
`SymbolicReference` fails during ref-name validation in all four
files/reftable and SHA-1/SHA-256 variants. The same failures were already
present in PR #2336, before the unrelated `patch_env()` change in PR #2340.
Use `PurePosixPath` for the test's Git reference names, which use forward
slashes on every platform. It still implements `os.PathLike`, preserving
coverage through `SymbolicReference` and direct and nested `merge_base()`
arguments alongside `PathLikeMock`. Keep native `Path` for filesystem
operations elsewhere in the module and preserve production validation.
Assisted-by: GPT 6.1 Sol
Co-authored-by: GPT 6.1 Sol <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters