From 3a469f2e93b8b15f631ece356792acf95b57b3fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Rowlands=20=28=EB=B3=80=EA=B8=B0=ED=98=B8=29?= Date: Thu, 18 Jun 2020 14:31:30 +0900 Subject: [PATCH] dvcignore: ignore empty (None) patterns (#4066) --- dvc/ignore.py | 1 + tests/func/test_ignore.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/dvc/ignore.py b/dvc/ignore.py index 2ec841349..d11c43053 100644 --- a/dvc/ignore.py +++ b/dvc/ignore.py @@ -39,6 +39,7 @@ class DvcIgnorePatterns(DvcIgnore): for ignore, group in groupby( regex_pattern_list, lambda x: x[1] ) + if ignore is not None ] def __call__(self, root, dirs, files): diff --git a/tests/func/test_ignore.py b/tests/func/test_ignore.py index d3a64435f..03b1e9567 100644 --- a/tests/func/test_ignore.py +++ b/tests/func/test_ignore.py @@ -166,3 +166,10 @@ def test_ignore_subrepo(tmp_dir, scm, dvc): for _ in subrepo.brancher(all_commits=True): assert subrepo.tree.exists(subrepo_dir / "foo") + + +def test_ignore_blank_line(tmp_dir, dvc): + tmp_dir.gen({"dir": {"ignored": "text", "other": "text2"}}) + tmp_dir.gen(DvcIgnore.DVCIGNORE_FILE, "foo\n\ndir/ignored") + + assert _files_set("dir", dvc.tree) == {"dir/other"}