dvcignore: fix bug in subrepo detection (#3880)

This commit is contained in:
Ruslan Kuprieiev
2020-05-27 12:13:53 +03:00
committed by GitHub
parent e8f6cd7f5b
commit 7027c631c5
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ class DvcIgnoreRepo(DvcIgnore):
def is_dvc_repo(directory):
from dvc.repo import Repo
return os.path.isdir(os.path.join(directory, Repo.DVC_DIR))
return os.path.isdir(os.path.join(root, directory, Repo.DVC_DIR))
dirs = [d for d in dirs if not is_dvc_repo(d)]
+9
View File
@@ -182,18 +182,27 @@ def test_meta_is_preserved(tmp_dir, dvc):
def test_parent_repo_collect_stages(tmp_dir, scm, dvc):
tmp_dir.gen({"subdir": {}})
tmp_dir.gen({"deep": {"dir": {}}})
subrepo_dir = tmp_dir / "subdir"
deep_subrepo_dir = tmp_dir / "deep" / "dir"
with subrepo_dir.chdir():
subrepo = Repo.init(subdir=True)
subrepo_dir.gen("subrepo_file", "subrepo file content")
subrepo.add("subrepo_file")
with deep_subrepo_dir.chdir():
deep_subrepo = Repo.init(subdir=True)
deep_subrepo_dir.gen("subrepo_file", "subrepo file content")
deep_subrepo.add("subrepo_file")
stages = dvc.collect(None)
subrepo_stages = subrepo.collect(None)
deep_subrepo_stages = deep_subrepo.collect(None)
assert stages == []
assert subrepo_stages != []
assert deep_subrepo_stages != []
def test_stage_strings_representation(tmp_dir, dvc, run_copy):