dvc.objects: use stub ignore in dvc.objects/dvc.data

This commit:
* defines a `Ignore` protocol in `dvc.objects`, that expects a `find` method.
  This will be used in dvc-data and dvc-objects instead of depending on dvc.ignore.
  dvcignore is expected to respect this protocol, which it does.
* renames `dvcignore` kwarg to `ignore` in `dvc-data` and `dvc-objects`.
* teaches dvc.cli that `IgnoreInCollectedError` is a known exception
   and is logged correctly and adds a test for the behaviour.

I am not happy that we need to hardcode `.dvcignore` in dvc-data
but I don't see any easy way, since we always try to avoid
staging if the tree contains .dvcignore file, even if .dvcignore
is not passed.
This commit is contained in:
Saugat Pachhai (सौगात)
2022-05-18 12:22:28 +03:00
committed by Ruslan Kuprieiev
parent 54917e3255
commit 32cd6c2c03
13 changed files with 125 additions and 64 deletions
+16
View File
@@ -4,6 +4,7 @@ import pytest
from funcy import raiser
from dvc.cli import main
from dvc.data.stage import IgnoreInCollectedDirError
from dvc.objects.cache import DiskError
from dvc.objects.fs.base import FileSystem, RemoteMissingDepsError
@@ -68,3 +69,18 @@ def test_remote_missing_deps_are_correctly_reported(
"Thank you!"
)
assert expected in caplog.text
def test_ignore_in_collected_dir_error_is_logged(tmp_dir, caplog, mocker):
error = IgnoreInCollectedDirError(".dvcignore", "dir")
mocker.patch(
"dvc.cli.parse_args",
return_value=Namespace(
func=raiser(error),
quiet=False,
verbose=True,
),
)
assert main() == 255
expected = ".dvcignore file should not be in collected dir path: 'dir'"
assert expected in caplog.text