Git adding case insenstiive

This commit is contained in:
2026-05-09 12:51:59 +02:00
parent e6a6968109
commit ad07de2e9a
+32
View File
@@ -25,6 +25,35 @@ def _read_json(path: Path) -> Any:
return json.loads(text) if text else {} return json.loads(text) if text else {}
def _resolve_case_insensitive(path: Path) -> Path:
"""Return the real on-disk path, resolving each component case-insensitively.
On case-insensitive filesystems (macOS) paths just work. On case-sensitive
ones (Linux/WSL) a mismatch between project.json and the actual directory
name causes a FileNotFoundError. This walks each component and picks the
first directory entry whose name matches case-insensitively, returning the
corrected path. If the path already exists, it is returned unchanged.
"""
if path.exists():
return path
resolved = path.anchor and Path(path.anchor) or Path(".")
for part in path.parts[len(Path(path.anchor).parts):]:
if (resolved / part).exists():
resolved = resolved / part
else:
try:
match = next(
(p for p in resolved.iterdir() if p.name.lower() == part.lower()),
None,
)
except (OSError, NotADirectoryError):
match = None
resolved = match if match else (resolved / part)
return resolved
def parse_manuscript( def parse_manuscript(
project_path: Path, project_path: Path,
) -> tuple[str, list[str], list[tuple[int, str]], list[Citation]]: ) -> tuple[str, list[str], list[tuple[int, str]], list[Citation]]:
@@ -267,6 +296,9 @@ def parse_slides(
else: else:
local_slides_path = project_path / "slides.json" local_slides_path = project_path / "slides.json"
# Resolve case-insensitively before cache lookup (handles Mac vs WSL casing).
local_slides_path = _resolve_case_insensitive(local_slides_path)
# Try cache fallback for reading JSON # Try cache fallback for reading JSON
slides_path, _ = resolve_with_cache(local_slides_path, project_path) slides_path, _ = resolve_with_cache(local_slides_path, project_path)
if not slides_path.exists(): if not slides_path.exists():