fix: call ripgrep with explicit utf-8 encoding. (#1199)

This commit is contained in:
Sola-ris
2026-01-23 07:04:09 +01:00
committed by GitHub
parent 4dc06835cb
commit 4c484bc4c6
3 changed files with 25 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ jobs:
libxcb-xinerama0 \
libxkbcommon-x11-0 \
libyaml-dev \
ripgrep \
x11-utils
- name: Execute pytest

View File

@@ -105,8 +105,8 @@ class RefreshTracker:
),
cwd=library_dir,
capture_output=True,
text=True,
shell=True,
encoding="UTF-8",
)
compiled_ignore_path.unlink()

View File

@@ -2,6 +2,7 @@
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import shutil
from pathlib import Path
from tempfile import TemporaryDirectory
@@ -29,3 +30,25 @@ def test_refresh_new_files(library: Library, exclude_mode: bool):
# Test if the single file was added
list(registry.refresh_dir(library_dir, force_internal_tools=True))
assert registry.files_not_in_library == [Path("FOO.MD")]
@pytest.mark.parametrize("library", [TemporaryDirectory()], indirect=True)
def test_refresh_multi_byte_filenames_ripgrep(library: Library):
assert shutil.which("rg") is not None
library_dir = unwrap(library.library_dir)
# Given
registry = RefreshTracker(library=library)
library.included_files.clear()
(library_dir / ".TagStudio").mkdir()
(library_dir / "こんにちは.txt").touch()
(library_dir / "emdash.txt").touch()
(library_dir / "apostrophe.txt").touch()
(library_dir / "umlaute äöü.txt").touch()
# Test if all files were added with their correct names and without exceptions
list(registry.refresh_dir(library_dir))
assert Path("こんにちは.txt") in registry.files_not_in_library
assert Path("emdash.txt") in registry.files_not_in_library
assert Path("apostrophe.txt") in registry.files_not_in_library
assert Path("umlaute äöü.txt") in registry.files_not_in_library