bugfix: get dump folder contents in respective output folder (#4034)

The relative path for external git directory was computed relative to
the root of the repo itself, which created a relative path which is
current working directory. So, all of the contents of the erepo to download
was dumped in the pwd rather than inside of it's own directory.

Fix #4033
This commit is contained in:
Saugat Pachhai
2020-06-12 20:31:18 +03:00
committed by GitHub
parent 9e7dc2640e
commit 9ff6fef53a
2 changed files with 8 additions and 6 deletions
+2 -4
View File
@@ -404,10 +404,8 @@ class RepoTree(BaseTree):
for root, _, files in self.walk(top):
root = PathInfo(root)
dest_dir = root.relative_to(top)
makedirs(dest_dir, exist_ok=True)
makedirs(dest, exist_ok=True)
for fname in files:
src = root / fname
dest = dest_dir / fname
with self.open(src, mode="rb") as fobj:
copy_fobj_to_file(fobj, dest)
copy_fobj_to_file(fobj, dest / fname)
+6 -2
View File
@@ -33,7 +33,9 @@ def test_get_repo_dir(tmp_dir, erepo_dir):
trees_equal(erepo_dir / "dir", "dir_imported")
def test_get_git_file(tmp_dir, erepo_dir):
@pytest.mark.parametrize("repo_type", ["git_dir", "erepo_dir"])
def test_get_git_file(request, tmp_dir, repo_type):
erepo_dir = request.getfixturevalue(repo_type)
src = "some_file"
dst = "some_file_imported"
@@ -45,7 +47,9 @@ def test_get_git_file(tmp_dir, erepo_dir):
assert (tmp_dir / dst).read_text() == "hello"
def test_get_git_dir(tmp_dir, erepo_dir):
@pytest.mark.parametrize("repo_type", ["git_dir", "erepo_dir"])
def test_get_git_dir(request, tmp_dir, repo_type):
erepo_dir = request.getfixturevalue(repo_type)
src = "some_directory"
dst = "some_directory_imported"