This commit is contained in:
Dani Hodovic
2019-12-05 21:05:03 +01:00
parent 9930e96390
commit 38bed227c6
3 changed files with 9 additions and 8 deletions
+3 -3
View File
@@ -268,9 +268,9 @@ class FileMissingError(DvcException):
)
class FileOutsideRepoError(DvcException):
def __init__(self, path, cause=None):
super(FileOutsideRepoError, self).__init__(
class PathOutsideRepoError(DvcException):
def __init__(self, path):
super(PathOutsideRepoError, self).__init__(
"The path '{}' is outside the target repository.".format(path)
)
+4 -3
View File
@@ -9,13 +9,14 @@ from dvc.exceptions import NotDvcRepoError
from dvc.exceptions import OutputNotFoundError
from dvc.exceptions import UrlNotDvcRepoError
from dvc.exceptions import NoOutputInExternalRepoError
from dvc.exceptions import FileOutsideRepoError
from dvc.exceptions import PathOutsideRepoError
from dvc.external_repo import external_repo
from dvc.path_info import PathInfo
from dvc.stage import Stage
from dvc.state import StateNoop
from dvc.utils import resolve_output
from dvc.utils.fs import remove
from dvc.utils.fs import path_isin
logger = logging.getLogger(__name__)
@@ -24,8 +25,8 @@ def _copy_git_file(repo, src, dst):
src_full_path = os.path.join(repo.root_dir, src)
dst_full_path = os.path.abspath(dst)
if repo.root_dir not in src_full_path:
raise FileOutsideRepoError(src)
if not path_isin(src_full_path, repo.root_dir):
raise PathOutsideRepoError(src)
if os.path.isdir(src_full_path):
shutil.copytree(src_full_path, dst_full_path)
+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 FileOutsideRepoError
from dvc.exceptions import PathOutsideRepoError
from dvc.repo import Repo
from dvc.system import System
from dvc.utils import makedirs
@@ -129,7 +129,7 @@ def test_get_full_dvc_path(erepo):
# https://github.com/iterative/dvc/pull/2837#discussion_r352123053
def test_fails_with_non_git_files(erepo):
with pytest.raises(FileOutsideRepoError):
with pytest.raises(PathOutsideRepoError):
Repo.get(erepo.root_dir, "/root/")