This commit is contained in:
Dani Hodovic
2019-12-06 20:20:25 +01:00
parent 811855ade2
commit d59bceb71a
2 changed files with 8 additions and 9 deletions
+6 -7
View File
@@ -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)
+2 -2
View File
@@ -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/")