diff --git a/dvc/repo/get.py b/dvc/repo/get.py index 9185a1ef7..534047504 100644 --- a/dvc/repo/get.py +++ b/dvc/repo/get.py @@ -24,11 +24,12 @@ def _copy_git_file(repo, src, dst, repo_url): src_full_path = os.path.join(repo.root_dir, src) dst_full_path = os.path.abspath(dst) + if os.path.isdir(src_full_path): + shutil.copytree(src_full_path, dst_full_path) + return + try: - if os.path.isdir(src_full_path): - shutil.copytree(src_full_path, dst_full_path) - else: - shutil.copy2(src_full_path, dst_full_path) + shutil.copy2(src_full_path, dst_full_path) except FileNotFoundError: raise PathOutsideRepoError(src, repo_url) @@ -80,7 +81,7 @@ def get(url, path, out=None, rev=None): return _copy_git_file(repo, path, out, url) if output_error: - raise output_error + raise OutputNotFoundError(path) with repo.state: repo.cloud.pull(output.get_used_cache()) @@ -90,7 +91,5 @@ def get(url, path, out=None, rev=None): except NotDvcRepoError: raise UrlNotDvcRepoError(url) - except OutputNotFoundError: - raise OutputNotFoundError(path) finally: remove(tmp_dir) diff --git a/tests/func/test_get.py b/tests/func/test_get.py index f838985fb..c7147447e 100644 --- a/tests/func/test_get.py +++ b/tests/func/test_get.py @@ -9,7 +9,7 @@ import pytest from dvc.config import Config from dvc.exceptions import GetDVCFileError from dvc.exceptions import UrlNotDvcRepoError -from dvc.exceptions import NoOutputInExternalRepoError +from dvc.exceptions import OutputNotFoundError from dvc.exceptions import PathOutsideRepoError from dvc.repo import Repo from dvc.system import System @@ -146,7 +146,7 @@ def test_non_cached_output(tmp_path, erepo): # https://github.com/iterative/dvc/pull/2837#discussion_r352123053 def test_fails_with_files_outside_repo(erepo): - with pytest.raises(NoOutputInExternalRepoError): + with pytest.raises(OutputNotFoundError): Repo.get(erepo.root_dir, "/root/")