From 8dd55800ca28d7f6bfb91ca7d304159e178038be Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 29 Dec 2021 13:47:55 +0200 Subject: [PATCH] fs: support root_marker (#25) fsspec filesystems don't yet have a notion of cwd, so "." should not be used. Instead, we should support using fs.root_marker ("" in our case), which is currently broken. --- scmrepo/fs.py | 2 +- tests/test_fs.py | 6 +++--- tests/test_git.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scmrepo/fs.py b/scmrepo/fs.py index dfebae84..c01da0e4 100644 --- a/scmrepo/fs.py +++ b/scmrepo/fs.py @@ -59,7 +59,7 @@ def __init__( def _get_key(self, path: str) -> Tuple[str, ...]: relparts = path.split(self.sep) - if relparts == ["."]: + if relparts == [self.root_marker]: return () return tuple(relparts) diff --git a/tests/test_fs.py b/tests/test_fs.py index 37bc677f..c6e8113a 100644 --- a/tests/test_fs.py +++ b/tests/test_fs.py @@ -82,7 +82,7 @@ def convert_to_sets(walk_results): for root, dirs, nondirs in walk_results ] - assert convert_to_sets(fs.walk(".")) == convert_to_sets( + assert convert_to_sets(fs.walk("")) == convert_to_sets( [ ("", ["data"], []), ("data", ["subdir"], []), @@ -116,8 +116,8 @@ def test_ls(tmp_dir: TmpDir, scm: Git): scm.add_commit(files, message="add") fs = scm.get_fs("master") - assert fs.ls(".", detail=False) == ["foo", "тест", "data"] - assert fs.ls(".") == { + assert fs.ls("", detail=False) == ["foo", "тест", "data"] + assert fs.ls("") == { "data": { "mode": 16384, "name": "data", diff --git a/tests/test_git.py b/tests/test_git.py index bf51bb03..d0eb1919 100644 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -126,7 +126,7 @@ def test_walk_with_submodules( files = [] dirs = [] fs = scm.get_fs("HEAD") - for _, dnames, fnames in fs.walk("."): + for _, dnames, fnames in fs.walk(""): dirs.extend(dnames) files.extend(fnames)