dvcfs: handle repo root

Fixes #7407
This commit is contained in:
Ruslan Kuprieiev
2022-02-21 04:23:43 +02:00
parent 30fa3fc41b
commit 82b0a3088f
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ class DvcFileSystem(FileSystem): # pylint:disable=abstract-method
fs_key = "repo"
key = self.path.parts(path)
if key == (".",):
if key == (".",) or key == ("",):
key = ()
return (fs_key, *key)
+14
View File
@@ -10,6 +10,20 @@ from dvc.hash_info import HashInfo
from dvc.utils.fs import remove
@pytest.mark.parametrize(
"path, key",
[
("", ("repo",)),
(".", ("repo",)),
("foo", ("repo", "foo")),
(os.path.join("dir", "foo"), ("repo", "dir", "foo")),
],
)
def test_get_key(tmp_dir, dvc, path, key):
fs = DvcFileSystem(repo=dvc)
assert fs._get_key(path) == key
def test_exists(tmp_dir, dvc):
tmp_dir.gen("foo", "foo")
dvc.add("foo")