Skip to content

Commit 27ab59c

Browse files
committed
pytest plugin(git): Set GITCONFIG for git_remote_repo_single_commit_post_init()
1 parent 24ea96b commit 27ab59c

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/libvcs/pytest_plugin.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
if TYPE_CHECKING:
2020
from typing_extensions import TypeAlias
2121

22+
from libvcs._internal.run import _ENV
23+
2224

2325
class MaxUniqueRepoAttemptsExceeded(exc.LibVCSException):
2426
"""Raised when exceeded threshold of attempts to find a unique repo destination."""
@@ -391,10 +393,17 @@ def fn(
391393
return fn
392394

393395

394-
def git_remote_repo_single_commit_post_init(remote_repo_path: pathlib.Path) -> None:
396+
def git_remote_repo_single_commit_post_init(
397+
remote_repo_path: pathlib.Path,
398+
env: "_ENV | None" = None,
399+
) -> None:
395400
"""Post-initialization: Create a test git repo with a single commit."""
396401
testfile_filename = "testfile.test"
397-
run(["touch", testfile_filename], cwd=remote_repo_path)
402+
run(
403+
["touch", testfile_filename],
404+
cwd=remote_repo_path,
405+
env={"GITCONFIG": str(gitconfig)},
406+
)
398407
run(["git", "add", testfile_filename], cwd=remote_repo_path)
399408
run(["git", "commit", "-m", "test file for dummyrepo"], cwd=remote_repo_path)
400409

@@ -403,11 +412,17 @@ def git_remote_repo_single_commit_post_init(remote_repo_path: pathlib.Path) -> N
403412
@skip_if_git_missing
404413
def git_remote_repo(
405414
create_git_remote_repo: CreateRepoPytestFixtureFn,
415+
gitconfig: pathlib.Path,
406416
) -> pathlib.Path:
407417
"""Copy the session-scoped Git repository to a temporary directory."""
408418
# TODO: Cache the effect of of this in a session-based repo
409419
repo_path = create_git_remote_repo()
410-
git_remote_repo_single_commit_post_init(remote_repo_path=repo_path)
420+
git_remote_repo_single_commit_post_init(
421+
remote_repo_path=repo_path,
422+
env={
423+
"GITCONFIG": str(gitconfig),
424+
},
425+
)
411426
return repo_path
412427

413428

0 commit comments

Comments
 (0)