import: check erepo is None before modifying url - fixes #3780 (#3781)

* import: check erepo is None before modifying url - fixes #3780

* import: add test to cover this local import
This commit is contained in:
Ned Letcher
2020-05-11 18:29:35 +03:00
committed by GitHub
parent 666e203bbb
commit 9f015fac1d
2 changed files with 12 additions and 2 deletions
+6 -2
View File
@@ -17,8 +17,12 @@ def imp_url(self, url, out=None, fname=None, erepo=None, locked=True):
out = resolve_output(url, out)
path, wdir, out = resolve_paths(self, out)
# NOTE: when user is importing something from within his own repository
if os.path.exists(url) and path_isin(os.path.abspath(url), self.root_dir):
# NOTE: when user is importing something from within their own repository
if (
erepo is None
and os.path.exists(url)
and path_isin(os.path.abspath(url), self.root_dir)
):
url = relpath(url, wdir)
stage = create_stage(
+6
View File
@@ -342,3 +342,9 @@ def test_import_pipeline_tracked_outs(
"file:///{}".format(fspath(tmp_dir)), "bar", out="baz"
)
assert (erepo_dir / "baz").read_text() == "foo"
def test_local_import(tmp_dir, dvc, scm):
tmp_dir.dvc_gen("foo", "foo", commit="init")
(tmp_dir / "outdir").mkdir()
dvc.imp(".", "foo", out="outdir")