Skip to content

Commit 1abcda1

Browse files
committed
fix: Handle UnicodeDecodeError in .gitignore files
Co-authored-by: cecli (openai/gemini_cli/gemini-2.5-pro)
1 parent 4a4e977 commit 1abcda1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cecli/watch.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ def load_gitignores(gitignore_paths: list[Path]) -> Optional[PathSpec]:
5555
] # Always ignore
5656
for path in gitignore_paths:
5757
if path.exists():
58-
with open(path) as f:
59-
patterns.extend(f.readlines())
58+
try:
59+
with open(path, "r", encoding="utf-8", errors="ignore") as f:
60+
patterns.extend(f.readlines())
61+
except Exception:
62+
pass # Ignore files that can't be read
6063

6164
return PathSpec.from_lines(GitWildMatchPattern, patterns) if patterns else None
6265

0 commit comments

Comments
 (0)