From e9a50e6c636ef4c998c4498966e1384a4eed044a Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 25 Jan 2026 09:22:29 -0600 Subject: [PATCH 1/4] test_pytest_plugin(test[xfail]): Add regression test for git_repo submodule file protocol why: Document the issue where git_repo fixture lacks set_home dependency, causing submodule operations to fail in isolated build environments what: - Add test_git_repo_fixture_submodule_file_protocol with xfail marker - Test isolates HOME to prove child processes can't find gitconfig - References GitHub issue #509 --- tests/test_pytest_plugin.py | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index 6289b7a3..2df02f9a 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -16,6 +16,7 @@ import pathlib from libvcs.pytest_plugin import CreateRepoPytestFixtureFn + from libvcs.sync.git import GitSync @pytest.mark.skipif(not shutil.which("git"), reason="git is not available") @@ -258,3 +259,54 @@ def test_gitconfig_submodule_file_protocol( # Verify submodule was actually added gitmodules = main_repo / ".gitmodules" assert gitmodules.exists(), "Submodule should create .gitmodules file" + + +@pytest.mark.skipif(not shutil.which("git"), reason="git is not available") +@pytest.mark.xfail(reason="git_repo fixture missing set_home dependency") +def test_git_repo_fixture_submodule_file_protocol( + git_repo: GitSync, + create_git_remote_repo: CreateRepoPytestFixtureFn, + git_commit_envvars: dict[str, str], + user_path: pathlib.Path, + tmp_path: pathlib.Path, + monkeypatch: pytest.MonkeyPatch, +) -> None: + """Test that git_repo fixture allows file:// protocol for submodule operations. + + This validates that the git_repo fixture has proper HOME setup so child + processes (spawned by git submodule add) can find $HOME/.gitconfig with + protocol.file.allow=always. + + Without set_home in git_repo, this test fails with: + fatal: transport 'file' not allowed + + See: https://github.com/vcs-python/libvcs/issues/509 + """ + from libvcs.pytest_plugin import git_remote_repo_single_commit_post_init + + # Isolate git config: set HOME to a clean path without protocol.file.allow + # This simulates what happens on a fresh build system like Arch Linux packaging + clean_home = tmp_path / "clean_home" + clean_home.mkdir() + monkeypatch.setenv("HOME", str(clean_home)) + monkeypatch.setenv("GIT_CONFIG_SYSTEM", os.devnull) + monkeypatch.delenv("GIT_CONFIG_GLOBAL", raising=False) + + # Create a repo to use as submodule source (with a commit so it can be cloned) + submodule_source = create_git_remote_repo() + git_remote_repo_single_commit_post_init( + remote_repo_path=submodule_source, + env=git_commit_envvars, + ) + + # Add submodule - this spawns child git clone that needs HOME set + # NOTE: We do NOT use the local config workaround here + result = git_repo.cmd.submodules.add( + repository=f"file://{submodule_source}", + path="vendor/lib", + ) + + assert "fatal" not in result.lower(), ( + f"git submodule add failed: {result}\n" + "git_repo fixture needs set_home dependency for child processes" + ) From c405217c2331da604da3e575c08d1e4f3c332ae6 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 25 Jan 2026 09:26:57 -0600 Subject: [PATCH 2/4] pytest_plugin(fix[git_repo]): Add set_home dependency for child processes why: Child processes spawned by git submodule operations need HOME set to find $HOME/.gitconfig with protocol.file.allow=always configuration what: - Add set_home fixture dependency to git_repo fixture - Fixes GitHub issue #509 for users of git_repo fixture --- src/libvcs/pytest_plugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libvcs/pytest_plugin.py b/src/libvcs/pytest_plugin.py index 8930ceb6..cf213fd2 100644 --- a/src/libvcs/pytest_plugin.py +++ b/src/libvcs/pytest_plugin.py @@ -701,6 +701,7 @@ def git_repo( projects_path: pathlib.Path, git_remote_repo: pathlib.Path, set_gitconfig: pathlib.Path, + set_home: None, # Needed for child processes (e.g. submodules) ) -> GitSync: """Pre-made git clone of remote repo checked out to user's projects dir.""" remote_repo_name = unique_repo_name(remote_repos_path=projects_path) From cb8747ea2a11e6a0529037236e5451d85f2e669f Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 25 Jan 2026 09:27:04 -0600 Subject: [PATCH 3/4] test_pytest_plugin(test): Remove xfail now that git_repo has set_home why: The git_repo fixture now has set_home dependency, so the test passes what: - Remove @pytest.mark.xfail from test_git_repo_fixture_submodule_file_protocol - Update docstring to document the fix --- tests/test_pytest_plugin.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index 2df02f9a..aa0896a3 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -262,13 +262,11 @@ def test_gitconfig_submodule_file_protocol( @pytest.mark.skipif(not shutil.which("git"), reason="git is not available") -@pytest.mark.xfail(reason="git_repo fixture missing set_home dependency") def test_git_repo_fixture_submodule_file_protocol( git_repo: GitSync, create_git_remote_repo: CreateRepoPytestFixtureFn, git_commit_envvars: dict[str, str], user_path: pathlib.Path, - tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch, ) -> None: """Test that git_repo fixture allows file:// protocol for submodule operations. @@ -277,20 +275,23 @@ def test_git_repo_fixture_submodule_file_protocol( processes (spawned by git submodule add) can find $HOME/.gitconfig with protocol.file.allow=always. - Without set_home in git_repo, this test fails with: - fatal: transport 'file' not allowed + The git_repo fixture depends on set_home to ensure child processes + (like git clone spawned by git submodule add) can find the test gitconfig. See: https://github.com/vcs-python/libvcs/issues/509 """ from libvcs.pytest_plugin import git_remote_repo_single_commit_post_init - # Isolate git config: set HOME to a clean path without protocol.file.allow - # This simulates what happens on a fresh build system like Arch Linux packaging - clean_home = tmp_path / "clean_home" - clean_home.mkdir() - monkeypatch.setenv("HOME", str(clean_home)) + # Verify that HOME is set to user_path where test gitconfig resides + assert os.environ.get("HOME") == str(user_path), ( + f"git_repo fixture should set HOME to user_path.\n" + f"Expected: {user_path}\n" + f"Actual: {os.environ.get('HOME')}\n" + "git_repo fixture is missing set_home dependency" + ) + + # Block system config to prevent interference monkeypatch.setenv("GIT_CONFIG_SYSTEM", os.devnull) - monkeypatch.delenv("GIT_CONFIG_GLOBAL", raising=False) # Create a repo to use as submodule source (with a commit so it can be cloned) submodule_source = create_git_remote_repo() @@ -299,7 +300,7 @@ def test_git_repo_fixture_submodule_file_protocol( env=git_commit_envvars, ) - # Add submodule - this spawns child git clone that needs HOME set + # Add submodule - this spawns child git clone that needs HOME set correctly # NOTE: We do NOT use the local config workaround here result = git_repo.cmd.submodules.add( repository=f"file://{submodule_source}", From 54d3187972b14446afbf28a039497c8d88334016 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 25 Jan 2026 09:41:36 -0600 Subject: [PATCH 4/4] docs(CHANGES): Add entry for #511 git_repo set_home fix why: Document the pytest plugin fix for users upgrading what: - Add changelog entry for git_repo fixture set_home dependency --- CHANGES | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES b/CHANGES index 2dafad36..7223b891 100644 --- a/CHANGES +++ b/CHANGES @@ -20,6 +20,13 @@ $ uv add libvcs --prerelease allow _Notes on the upcoming release will go here._ +### Tests + +- pytest plugin: Add `set_home` dependency to `git_repo` fixture (#511) + + Follow-up to #510 for #509: Ensures child processes spawned by git submodule + operations can find `$HOME/.gitconfig` with `protocol.file.allow=always`. + ## libvcs 0.38.3 (2026-01-25) ### Tests