Skip to content

Commit

Permalink
fs: support root_marker (#25)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
efiop authored and skshetry committed Apr 6, 2022
1 parent f29ad51 commit 8dd5580
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scmrepo/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"], []),
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 8dd5580

Please sign in to comment.