fix(core): Add .geminiignore support to SearchText tool (#13763)

Co-authored-by: Gaurav <39389231+gsquared94@users.noreply.github.com>
This commit is contained in:
Serghei
2025-12-22 06:25:26 +02:00
committed by GitHub
parent b923604602
commit 58fd00a3df
5 changed files with 183 additions and 0 deletions

View File

@@ -11,6 +11,8 @@ import ignore from 'ignore';
export interface GeminiIgnoreFilter {
isIgnored(filePath: string): boolean;
getPatterns(): string[];
getIgnoreFilePath(): string | null;
hasPatterns(): boolean;
}
export class GeminiIgnoreParser implements GeminiIgnoreFilter {
@@ -78,4 +80,26 @@ export class GeminiIgnoreParser implements GeminiIgnoreFilter {
getPatterns(): string[] {
return this.patterns;
}
/**
* Returns the path to .geminiignore file if it exists and has patterns.
* Useful for tools like ripgrep that support --ignore-file flag.
*/
getIgnoreFilePath(): string | null {
if (!this.hasPatterns()) {
return null;
}
return path.join(this.projectRoot, '.geminiignore');
}
/**
* Returns true if .geminiignore exists and has patterns.
*/
hasPatterns(): boolean {
if (this.patterns.length === 0) {
return false;
}
const ignoreFilePath = path.join(this.projectRoot, '.geminiignore');
return fs.existsSync(ignoreFilePath);
}
}