Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix git ls-file parsing in iter_gitworktree() #421

Merged
merged 3 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datalad_next/iter_collections/gitworktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class GitWorktreeFileSystemItem(FileSystemItem):

# stolen from GitRepo.get_content_info()
_lsfiles_props_re = re.compile(
r'(?P<mode>[0-9]+) (?P<gitsha>.*) (.*)\t(?P<fname>.*)$'
r'(?P<mode>[0-9]+) (?P<gitsha>.*) ([^\t]*)\t(?P<fname>.*)$'
)

_mode_type_map = {
Expand Down
21 changes: 20 additions & 1 deletion datalad_next/iter_collections/tests/test_itergitworktree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from pathlib import PurePath
from pathlib import (
PurePath,
PurePosixPath,
)

import pytest

from ..gitworktree import (
GitWorktreeItem,
GitWorktreeFileSystemItem,
Expand Down Expand Up @@ -72,3 +78,16 @@ def test_iter_gitworktree(existing_dataset):
checked_untracked = True
assert checked_tracked
assert checked_untracked


def test_name_starting_with_tab(existing_dataset):
ds = existing_dataset
if ds.repo.is_crippled_fs():
pytest.skip("not applicable on crippled filesystems")
tabbed_file_name = "\ttab.txt"
tabbed_name = ds.pathobj / tabbed_file_name
tabbed_name.write_text('name of this file starts with a tab')
ds.save()

iter_names = [item.name for item in iter_gitworktree(ds.pathobj)]
assert PurePosixPath(tabbed_file_name) in iter_names