Skip to content

Commit ff48765

Browse files
codexByron
authored andcommitted
test(refs): keep PathLike reference names portable on Windows
`test_revision_arguments_preserve_pathlike_paths` fails in the Windows `Python package` jobs because `Path("refs/heads/main")` emits `refs\heads\main`. Git rejects backslashes in reference names, so the test raises `ValueError: Invalid reference` before exercising revision argument handling. All four combinations of SHA-1/SHA-256 and files/reftable fail. The same failures are present in the final Windows Python 3.14t job for the introducing PR #2336, so this is inherited by PR #2339 rather than caused by its blame-content change. Use `PurePosixPath` for the reference-name test parameter. Reference names use forward slashes on every platform; filesystem paths elsewhere in the tests continue to use `Path`. Keep `PathLikeMock` coverage and the existing reference validation unchanged. Validation: 28 focused reference/revision tests pass on each of the `cli` and `gix` backends, including all eight PathLike cases, nested merge-base operands, reflog walks, fork-point lookup, and remote archives. Both blame-content regressions also pass on each backend. Ruff 0.17.2 lint and formatting checks pass for `test/test_refs.py`; `git diff --check` passes. Windows validation is left to the PR's CI matrix. Agent-Model: unknown
1 parent 35027d1 commit ff48765

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎test/test_refs.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import tarfile
1111
import unittest
1212
from itertools import chain
13-
from pathlib import Path
13+
from pathlib import Path, PurePosixPath
1414
from unittest.mock import Mock, patch
1515

1616
import pytest
@@ -270,7 +270,7 @@ def test_merge_base_preserves_nested_reference_arguments(object_format, ref_form
270270

271271
@pytest.mark.parametrize("object_format", ["sha1", "sha256"])
272272
@pytest.mark.parametrize("ref_format", ["files", "reftable"])
273-
@pytest.mark.parametrize("path_type", [Path, PathLikeMock])
273+
@pytest.mark.parametrize("path_type", [PurePosixPath, PathLikeMock])
274274
def test_revision_arguments_preserve_pathlike_paths(object_format, ref_format, path_type):
275275
with fixture_repo("exact-refs.sh", object_format, ref_format, "shadowed") as repo:
276276
local = repo.head.commit

0 commit comments

Comments
 (0)