Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dvc/ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def _get_trie_pattern(self, dirname):

def _is_ignored(self, path, is_dir=False):
if self._outside_repo(path):
return True
return False
dirname, basename = os.path.split(os.path.normpath(path))
ignore_pattern = self._get_trie_pattern(dirname)
if ignore_pattern:
Expand All @@ -296,6 +296,7 @@ def is_ignored_dir(self, path, ignore_subrepos=True):
return self._is_ignored(path, True)

def is_ignored_file(self, path):
path = os.path.abspath(path)
return self._is_ignored(path, False)

def _outside_repo(self, path):
Expand Down
11 changes: 9 additions & 2 deletions tests/func/test_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,17 @@ def test_match_nested(tmp_dir, dvc):
def test_ignore_external(tmp_dir, scm, dvc, tmp_path_factory):
tmp_dir.gen(".dvcignore", "*.backup\ntmp")
ext_dir = TmpDir(os.fspath(tmp_path_factory.mktemp("external_dir")))
ext_dir.gen({"y.backup": "y", "tmp": "ext tmp"})
ext_dir.gen({"y.backup": "y", "tmp": {"file": "ext tmp"}})

result = {relpath(f, ext_dir) for f in dvc.tree.walk_files(ext_dir)}
assert result == {"y.backup", "tmp"}
assert result == {"y.backup", os.path.join("tmp", "file")}
assert (
dvc.tree.dvcignore.is_ignored_dir(os.fspath(ext_dir / "tmp")) is False
)
assert (
dvc.tree.dvcignore.is_ignored_file(os.fspath(ext_dir / "y.backup"))
is False
)


def test_ignore_subrepo(tmp_dir, scm, dvc):
Expand Down