Skip to content

Commit 4c484bc

Browse files
authored
fix: call ripgrep with explicit utf-8 encoding. (#1199)
1 parent 4dc0683 commit 4c484bc

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

.github/workflows/pytest.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
libxcb-xinerama0 \
4444
libxkbcommon-x11-0 \
4545
libyaml-dev \
46+
ripgrep \
4647
x11-utils
4748
4849
- name: Execute pytest

src/tagstudio/core/library/refresh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def __get_dir_list(self, library_dir: Path, ignore_patterns: list[str]) -> list[
105105
),
106106
cwd=library_dir,
107107
capture_output=True,
108-
text=True,
109108
shell=True,
109+
encoding="UTF-8",
110110
)
111111
compiled_ignore_path.unlink()
112112

tests/macros/test_refresh_dir.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the GPL-3.0 License.
33
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
44

5+
import shutil
56
from pathlib import Path
67
from tempfile import TemporaryDirectory
78

@@ -29,3 +30,25 @@ def test_refresh_new_files(library: Library, exclude_mode: bool):
2930
# Test if the single file was added
3031
list(registry.refresh_dir(library_dir, force_internal_tools=True))
3132
assert registry.files_not_in_library == [Path("FOO.MD")]
33+
34+
35+
@pytest.mark.parametrize("library", [TemporaryDirectory()], indirect=True)
36+
def test_refresh_multi_byte_filenames_ripgrep(library: Library):
37+
assert shutil.which("rg") is not None
38+
39+
library_dir = unwrap(library.library_dir)
40+
# Given
41+
registry = RefreshTracker(library=library)
42+
library.included_files.clear()
43+
(library_dir / ".TagStudio").mkdir()
44+
(library_dir / "こんにちは.txt").touch()
45+
(library_dir / "em–dash.txt").touch()
46+
(library_dir / "apostrophe’.txt").touch()
47+
(library_dir / "umlaute äöü.txt").touch()
48+
49+
# Test if all files were added with their correct names and without exceptions
50+
list(registry.refresh_dir(library_dir))
51+
assert Path("こんにちは.txt") in registry.files_not_in_library
52+
assert Path("em–dash.txt") in registry.files_not_in_library
53+
assert Path("apostrophe’.txt") in registry.files_not_in_library
54+
assert Path("umlaute äöü.txt") in registry.files_not_in_library

0 commit comments

Comments
 (0)