8000 refactor!(pytest plugin[git]) Cache `git_repo` · vcs-python/libvcs@d769e0a · GitHub
[go: up one dir, main page]

Skip to content

Commit d769e0a

Browse files
committed
refactor!(pytest plugin[git]) Cache git_repo
1 parent a70eb87 commit d769e0a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/libvcs/pytest_plugin.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,26 @@ def hg_remote_repo(
620620

621621

622622
@pytest.fixture
623-
def git_repo(projects_path: pathlib.Path, git_remote_repo: pathlib.Path) -> GitSync:
623+
def git_repo(
624+
remote_repos_path: pathlib.Path,
625+
projects_path: pathlib.Path,
626+
git_remote_repo: pathlib.Path,
627+
) -> GitSync:
624628
"""Pre-made git clone of remote repo checked out to user's projects dir."""
629+
remote_repo_name = unique_repo_name(remote_repos_path=projects_path)
630+
new_checkout_path = projects_path / remote_repo_name
631+
master_copy = remote_repos_path / "git_repo"
632+
633+
if master_copy.exists():
634+
shutil.copytree(master_copy, new_checkout_path)
635+
return GitSync(
636+
url=f"file://{git_remote_repo}",
637+
path=str(new_checkout_path),
638+
)
639+
625640
git_repo = GitSync(
626641
url=f"file://{git_remote_repo}",
627-
path=str(projects_path / "git_repo"),
642+
path=master_copy,
628643
remotes={
629644
"origin": GitRemote(
630645
name="origin",

0 commit comments

Comments
 (0)
0