From 6205d0091610bea8bdf45f61cefcde955dd2a1cd Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 25 Jan 2026 08:14:00 -0600 Subject: [PATCH 1/4] test_pytest_plugin(test): Add regression test for submodule file:// protocol (#509) why: Reproduce the "transport 'file' not allowed" error that occurs in strict build environments when git submodule operations spawn child processes that don't inherit local repo config what: - Add test_gitconfig_submodule_file_protocol test - Uses monkeypatch to simulate isolated git environment - Marked xfail until gitconfig fixture is fixed --- tests/test_pytest_plugin.py | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index 329a6ea60..078bc5e06 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -2,7 +2,9 @@ from __future__ import annotations +import os import shutil +import subprocess import textwrap import typing as t @@ -176,3 +178,86 @@ def test_git_bare_repo_sync_and_commit( # Test result = pytester.runpytest(str(first_test_filename)) result.assert_outcomes(passed=2) + + +@pytest.mark.skipif(not shutil.which("git"), reason="git is not available") +@pytest.mark.xfail( + reason="gitconfig fixture lacks protocol.file.allow=always for submodules (#509)", +) +def test_gitconfig_submodule_file_protocol( + gitconfig: pathlib.Path, + user_path: pathlib.Path, + tmp_path: pathlib.Path, + monkeypatch: pytest.MonkeyPatch, +) -> None: + """Test that gitconfig fixture allows file:// protocol for git submodule operations. + + Git submodule operations spawn child processes that don't inherit local repo config. + The child `git clone` process needs protocol.file.allow=always in global config. + + Without this setting, submodule operations fail with: + fatal: transport 'file' not allowed + + This reproduces GitHub issue #509 where tests fail in strict build environments + (like Arch Linux packaging) that don't have protocol.file.allow set globally. + + See: https://github.com/vcs-python/libvcs/issues/509 + """ + # Isolate git config: use fixture's gitconfig via HOME, block only system config + # Note: We don't block GIT_CONFIG_GLOBAL because git falls back to $HOME/.gitconfig + # when GIT_CONFIG_GLOBAL is unset, which is where our fixture puts the config + monkeypatch.setenv("HOME", str(user_path)) + monkeypatch.setenv("GIT_CONFIG_SYSTEM", os.devnull) + monkeypatch.delenv("GIT_CONFIG_GLOBAL", raising=False) + + # Create a source repository to use as submodule + submodule_source = tmp_path / "submodule_source" + submodule_source.mkdir() + subprocess.run( + ["git", "init"], + cwd=submodule_source, + check=True, + capture_output=True, + ) + subprocess.run( + ["git", "commit", "--allow-empty", "-m", "initial"], + cwd=submodule_source, + check=True, + capture_output=True, + ) + + # Create a main repository + main_repo = tmp_path / "main_repo" + main_repo.mkdir() + subprocess.run( + ["git", "init"], + cwd=main_repo, + check=True, + capture_output=True, + ) + subprocess.run( + ["git", "commit", "--allow-empty", "-m", "initial"], + cwd=main_repo, + check=True, + capture_output=True, + ) + + # Try to add submodule using file:// protocol + # This spawns a child git clone that needs protocol.file.allow=always + result = subprocess.run( + ["git", "submodule", "add", str(submodule_source), "vendor/lib"], + cwd=main_repo, + capture_output=True, + text=True, + ) + + # Assert: submodule add should succeed (no "fatal" errors) + assert "fatal" not in result.stderr.lower(), ( + f"git submodule add failed with: {result.stderr}\n" + 'This indicates gitconfig fixture is missing [protocol "file"] allow = always' + ) + assert result.returncode == 0, f"git submodule add failed: {result.stderr}" + + # Verify submodule was actually added + gitmodules = main_repo / ".gitmodules" + assert gitmodules.exists(), "Submodule should create .gitmodules file" From 56b812af7cb4ce8944994db1a90ddca2ba82e29b Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 25 Jan 2026 08:16:34 -0600 Subject: [PATCH 2/4] pytest_plugin(fix[gitconfig]): Allow file:// protocol for submodule tests why: git submodule operations spawn child processes that don't inherit local repo config, causing "transport 'file' not allowed" errors in strict build environments (#509) what: - Add [protocol "file"] allow = always to gitconfig fixture --- src/libvcs/pytest_plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libvcs/pytest_plugin.py b/src/libvcs/pytest_plugin.py index cbaeeb516..8930ceb63 100644 --- a/src/libvcs/pytest_plugin.py +++ b/src/libvcs/pytest_plugin.py @@ -165,6 +165,8 @@ def gitconfig( name = {vcs_name} [color] diff = auto + [protocol "file"] + allow = always """, ), encoding="utf-8", From d305272149f5a4a5a56df1fac8709ca83db48563 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 25 Jan 2026 08:17:21 -0600 Subject: [PATCH 3/4] test_pytest_plugin(chore): Remove xfail now that #509 is fixed why: The gitconfig fixture now includes protocol.file.allow=always what: - Remove xfail marker from test_gitconfig_submodule_file_protocol --- tests/test_pytest_plugin.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index 078bc5e06..6289b7a34 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -181,9 +181,6 @@ def test_git_bare_repo_sync_and_commit( @pytest.mark.skipif(not shutil.which("git"), reason="git is not available") -@pytest.mark.xfail( - reason="gitconfig fixture lacks protocol.file.allow=always for submodules (#509)", -) def test_gitconfig_submodule_file_protocol( gitconfig: pathlib.Path, user_path: pathlib.Path, From f2ef0fb6515fb2c722c4b43e5379382f77031e4a Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 25 Jan 2026 08:35:33 -0600 Subject: [PATCH 4/4] docs(CHANGES): Add entry for #510 file protocol fix why: Document the pytest plugin fix for strict build environments what: - Add Tests section for 0.39.x release - Note the protocol.file.allow=always addition to gitconfig fixture --- CHANGES | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGES b/CHANGES index 44481e419..1ef4718ba 100644 --- a/CHANGES +++ b/CHANGES @@ -20,6 +20,14 @@ $ uv add libvcs --prerelease allow _Notes on the upcoming release will go here._ +### Tests + +- pytest plugin: Add `protocol.file.allow=always` to `gitconfig` fixture (#510) + + Fixes #509: "transport 'file' not allowed" errors in strict build + environments (e.g., Arch Linux packaging) where git submodule operations + spawn child processes that don't inherit local repo config. + ## libvcs 0.38.2 (2026-01-24)