From 7027c631c56aab1a9575583abfb792a3a64811d2 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 27 May 2020 12:13:53 +0300 Subject: [PATCH] dvcignore: fix bug in subrepo detection (#3880) --- dvc/ignore.py | 2 +- tests/func/test_stage.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dvc/ignore.py b/dvc/ignore.py index 384ba38bd..9b42c7547 100644 --- a/dvc/ignore.py +++ b/dvc/ignore.py @@ -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)] diff --git a/tests/func/test_stage.py b/tests/func/test_stage.py index 2d7c9ac36..599d99134 100644 --- a/tests/func/test_stage.py +++ b/tests/func/test_stage.py @@ -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):