Skip to content

RepoTree: preserve relative paths in copytree() #4133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dvc/repo/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,12 @@ def copytree(self, top, dest):

for root, _, files in self.walk(top):
root = PathInfo(root)
makedirs(dest, exist_ok=True)
dest_dir = dest / root.relative_to(top)
makedirs(dest_dir, exist_ok=True)
for fname in files:
src = root / fname
with self.open(src, mode="rb") as fobj:
copy_fobj_to_file(fobj, dest / fname)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dest here was the top level destination path, rather than the expected relative path

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I should not have removed that without thinking once. My bad.

copy_fobj_to_file(fobj, dest_dir / fname)

@property
def hash_jobs(self):
Expand Down
4 changes: 3 additions & 1 deletion tests/func/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def test_get_git_dir(tmp_dir, erepo):
src = "some_directory"
dst = "some_directory_imported"

erepo.scm_gen({src: {"file.txt": "hello"}}, commit="add a regular dir")
erepo.scm_gen(
{src: {"dir": {"file.txt": "hello"}}}, commit="add a regular dir"
)

Repo.get(os.fspath(erepo), src, dst)

Expand Down