gemini-cli
gemini-cli copied to clipboard
fix(core): Add `.geminiignore` support to SearchText tool
The SearchText (ripgrep) tool was not respecting .geminiignore patterns, causing subagents to search through files that users explicitly wanted to exclude. This fix adds .geminiignore
support by leveraging ripgrep's native --ignore-file flag, ensuring consistent ignore behavior across all tools
Details
- Extended
GeminiIgnoreParserwithgetIgnoreFilePath()to return the.geminiignorepath when it exists and has valid patterns, andhasPatterns()to check if any patterns are defined - Added an existence check in
getIgnoreFilePath()to handle the race condition where the file could be deleted after the parser is instantiated - Updated
RipGrepToolto cache theGeminiIgnoreParserinstance, avoiding redundant file I/O on repeated tool calls - Ripgrep natively handles
.gitignore, so no changes needed there - Added 8 unit tests for the new 1GeminiIgnoreParser` methods
Related Issues
Partially Fixes: https://github.com/google-gemini/gemini-cli/issues/13651
How to Validate
- Create a file (example
file.md) with 1 word "carrot" in it - add this file to
.geminiignore - gemini "please find "carrot" in the project"
- observe that result is not found
behaviour before fix:
- I found one instance of 'carrot' in
file.md. file.md*: Line 1 (carrot)
Pre-Merge Checklist
- [ ] Updated relevant documentation and README (if needed)
- [x] Added/updated tests (if needed)
- [x] Noted breaking changes (if any)
- [ ] Validated on required platforms/methods:
- [x] MacOS
- [x] npm run
- [x] npx
- [ ] Docker
- [ ] Podman
- [ ] Seatbelt
- [ ] Windows
- [ ] npm run
- [ ] npx
- [ ] Docker
- [ ] Linux
- [ ] npm run
- [ ] npx
- [ ] Docker
- [x] MacOS