Skip to content

Commit

Permalink
dest for git clone is a directory
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Mar 21, 2024
1 parent 14bde0f commit 481b854
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def get_dependency(


def copy_path(source: Path, dest: Path) -> None:
if dest.is_symlink() or dest.is_file():
dest.unlink() # missing_ok is only available in Python >= 3.8
elif dest.is_dir():
if dest.is_dir():
shutil.rmtree(dest)
else:
dest.unlink(missing_ok=True)

if source.is_dir():
shutil.copytree(source, dest)
Expand Down Expand Up @@ -111,12 +111,13 @@ def mock_clone(

assert parsed.resource is not None
folder = FIXTURE_PATH / "git" / parsed.resource / path
assert folder.is_dir()

if not source_root:
source_root = Path(Config.create().get("cache-dir")) / "src"

dest = source_root / path
dest.parent.mkdir(parents=True, exist_ok=True)
dest.mkdir(parents=True, exist_ok=True)

copy_path(folder, dest)
return MockDulwichRepo(dest)
Expand Down

0 comments on commit 481b854

Please sign in to comment.