mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
output: local: use repo tree if possible (#4125)
This commit is contained in:
@@ -5,6 +5,7 @@ from urllib.parse import urlparse
|
||||
from dvc.exceptions import DvcException
|
||||
from dvc.istextfile import istextfile
|
||||
from dvc.output.base import BaseOutput
|
||||
from dvc.scm.tree import is_working_tree
|
||||
from dvc.utils import relpath
|
||||
from dvc.utils.fs import path_isin
|
||||
|
||||
@@ -22,6 +23,8 @@ class LocalOutput(BaseOutput):
|
||||
path = relpath(path, stage.wdir)
|
||||
|
||||
super().__init__(stage, path, *args, **kwargs)
|
||||
if self.is_in_repo and self.repo and is_working_tree(self.repo.tree):
|
||||
self.tree = self.repo.tree
|
||||
|
||||
def _parse_path(self, tree, path):
|
||||
parsed = urlparse(path)
|
||||
|
||||
@@ -364,3 +364,28 @@ def test_pattern_trie_tree(tmp_dir, dvc):
|
||||
)
|
||||
== ignore_pattern_bottom
|
||||
)
|
||||
|
||||
|
||||
def test_ignore_in_added_dir(tmp_dir, dvc):
|
||||
tmp_dir.gen(
|
||||
{
|
||||
"dir": {
|
||||
"sub": {
|
||||
"ignored": {"content": "ignored content"},
|
||||
"not_ignored": "not ignored content",
|
||||
}
|
||||
},
|
||||
".dvcignore": "**/ignored",
|
||||
}
|
||||
)
|
||||
dvc.tree.__dict__.pop("dvcignore", None)
|
||||
|
||||
ignored_path = tmp_dir / "dir" / "sub" / "ignored"
|
||||
assert not dvc.tree.exists(PathInfo(ignored_path))
|
||||
assert ignored_path.exists()
|
||||
|
||||
dvc.add("dir")
|
||||
shutil.rmtree(ignored_path)
|
||||
dvc.checkout()
|
||||
|
||||
assert not ignored_path.exists()
|
||||
|
||||
Reference in New Issue
Block a user