checkout: use dvcignore

Fixes #7374
This commit is contained in:
Alex Hall
2022-07-07 17:20:30 +08:00
committed by Gao
parent 892b235d0b
commit 182a22b8f6
2 changed files with 25 additions and 1 deletions
+1 -1
View File
@@ -583,6 +583,7 @@ class Output:
from dvc_data.checkout import CheckoutError as _CheckoutError
from dvc_data.checkout import LinkError, PromptError
kwargs.setdefault("ignore", self.dvcignore)
try:
return checkout(*args, **kwargs)
except PromptError as exc:
@@ -627,7 +628,6 @@ class Output:
obj,
self.odb,
relink=True,
ignore=self.dvcignore,
state=self.repo.state,
prompt=prompt.confirm,
)
+24
View File
@@ -418,3 +418,27 @@ def test_run_dvcignored_dep(tmp_dir, dvc, run_copy):
tmp_dir.gen({".dvcignore": "dir\n", "dir": {"foo": "foo"}})
run_copy(os.path.join("dir", "foo"), "bar", name="copy-foo-to-bar")
assert (tmp_dir / "bar").read_text() == "foo"
def test_pull_ignore(tmp_dir, dvc, local_cloud):
from dvc.utils.fs import remove
tmp_dir.dvc_gen(
{
".dvcignore": "data/processed/",
"data": {"foo": "foo", "processed": {"bar": "bar"}},
}
)
tmp_dir.add_remote(config=local_cloud.config)
dvc.add("data")
dvc.push()
foo_path = tmp_dir / "data" / "foo"
foo_path.unlink()
assert not foo_path.exists()
remove(tmp_dir / ".dvc/cache")
dvc.pull()
assert foo_path.exists()
assert foo_path.read_text() == "foo"