This commit is contained in:
Dani Hodovic
2019-12-05 21:05:03 +01:00
parent 20e7696da3
commit b17d1c5b04
2 changed files with 5 additions and 8 deletions
+1 -3
View File
@@ -14,7 +14,6 @@ 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__)
@@ -46,8 +45,7 @@ def get(url, path, out=None, rev=None):
try:
with external_repo(cache_dir=tmp_dir, url=url, rev=rev) as repo:
full_path = os.path.join(repo.root_dir, path)
path_in_repo = path_isin(full_path, repo.root_dir)
if os.path.exists(full_path) and path_in_repo:
if os.path.exists(full_path) and not os.path.isabs(path):
_copy_git_file(repo, path, out)
return
+4 -5
View File
@@ -3,7 +3,6 @@ from __future__ import unicode_literals
import filecmp
import logging
import os
import tempfile
import pytest
@@ -128,18 +127,18 @@ def test_get_full_dvc_path(erepo):
assert filecmp.cmp(external_data, "ext_data_imported", shallow=False)
def test_non_cached_output(request, erepo):
def test_non_cached_output(tmp_path, erepo):
os.chdir(erepo.root_dir)
erepo.dvc.run(
outs_no_cache=["non_cached_file"], cmd="echo hello > non_cached_file"
)
erepo.dvc.scm.add(["non_cached_file", "non_cached_file.dvc"])
erepo.dvc.scm.commit("add non-cached output")
new_dir = tempfile.mkdtemp(prefix=request.node.name + "_")
os.chdir(new_dir)
os.chdir(tmp_path)
Repo.get(erepo.root_dir, "non_cached_file")
assert os.path.isfile("non_cached_file")
src = os.path.join(erepo.root_dir, "non_cached_file")
assert os.path.isfile("non_cached_file")
assert filecmp.cmp(src, "non_cached_file", shallow=False)