mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-27 05:24:34 -07:00
Add .geminiignore support to the glob tool. (#8086)
This commit is contained in:
committed by
GitHub
parent
ef70c17936
commit
0e3a0d7dc5
@@ -16,6 +16,12 @@ export interface FilterFilesOptions {
|
||||
respectGeminiIgnore?: boolean;
|
||||
}
|
||||
|
||||
export interface FilterReport {
|
||||
filteredPaths: string[];
|
||||
gitIgnoredCount: number;
|
||||
geminiIgnoredCount: number;
|
||||
}
|
||||
|
||||
export class FileDiscoveryService {
|
||||
private gitIgnoreFilter: GitIgnoreFilter | null = null;
|
||||
private geminiIgnoreFilter: GitIgnoreFilter | null = null;
|
||||
@@ -65,6 +71,42 @@ export class FileDiscoveryService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a list of file paths based on git ignore rules and returns a report
|
||||
* with counts of ignored files.
|
||||
*/
|
||||
filterFilesWithReport(
|
||||
filePaths: string[],
|
||||
opts: FilterFilesOptions = {
|
||||
respectGitIgnore: true,
|
||||
respectGeminiIgnore: true,
|
||||
},
|
||||
): FilterReport {
|
||||
const filteredPaths: string[] = [];
|
||||
let gitIgnoredCount = 0;
|
||||
let geminiIgnoredCount = 0;
|
||||
|
||||
for (const filePath of filePaths) {
|
||||
if (opts.respectGitIgnore && this.shouldGitIgnoreFile(filePath)) {
|
||||
gitIgnoredCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (opts.respectGeminiIgnore && this.shouldGeminiIgnoreFile(filePath)) {
|
||||
geminiIgnoredCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
filteredPaths.push(filePath);
|
||||
}
|
||||
|
||||
return {
|
||||
filteredPaths,
|
||||
gitIgnoredCount,
|
||||
geminiIgnoredCount,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a single file should be git-ignored
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user