Skip to content

Commit 07a35c7

Browse files
committed
refactor!(pytest plugin[git]) Cache git_repo
1 parent ecc216f commit 07a35c7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/libvcs/pytest_plugin.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,20 @@ def hg_remote_repo(
622622
@pytest.fixture
623623
def git_repo(projects_path: pathlib.Path, git_remote_repo: pathlib.Path) -> GitSync:
624624
"""Pre-made git clone of remote repo checked out to user's projects dir."""
625+
remote_repo_name = unique_repo_name(remote_repos_path=projects_path)
626+
new_checkout_path = projects_path / remote_repo_name
627+
master_copy = projects_path / "git_repo"
628+
629+
if master_copy.exists():
630+
shutil.copytree(master_copy, new_checkout_path)
631+
return GitSync(
632+
url=f"file://{git_remote_repo}",
633+
path=str(new_checkout_path),
634+
)
635+
625636
git_repo = GitSync(
626637
url=f"file://{git_remote_repo}",
627-
path=str(projects_path / "git_repo"),
638+
path=master_copy,
628639
remotes={
629640
"origin": GitRemote(
630641
name="origin",

0 commit comments

Comments
 (0)