refactor: Switch over to unified shouldIgnoreFile (#11815)

This commit is contained in:
Eric Rahm
2025-10-24 18:55:12 -07:00
committed by GitHub
parent 145e099ca5
commit b1059f891f
6 changed files with 51 additions and 84 deletions
+6 -2
View File
@@ -38,6 +38,10 @@ describe('ReadFileTool', () => {
getFileSystemService: () => new StandardFileSystemService(),
getTargetDir: () => tempRootDir,
getWorkspaceContext: () => createMockWorkspaceContext(tempRootDir),
getFileFilteringOptions: () => ({
respectGitIgnore: true,
respectGeminiIgnore: true,
}),
storage: {
getProjectTempDir: () => path.join(tempRootDir, '.temp'),
},
@@ -462,7 +466,7 @@ describe('ReadFileTool', () => {
const params: ReadFileToolParams = {
absolute_path: ignoredFilePath,
};
const expectedError = `File path '${ignoredFilePath}' is ignored by .geminiignore pattern(s).`;
const expectedError = `File path '${ignoredFilePath}' is ignored by configured ignore patterns.`;
expect(() => tool.build(params)).toThrow(expectedError);
});
@@ -474,7 +478,7 @@ describe('ReadFileTool', () => {
const params: ReadFileToolParams = {
absolute_path: ignoredFilePath,
};
const expectedError = `File path '${ignoredFilePath}' is ignored by .geminiignore pattern(s).`;
const expectedError = `File path '${ignoredFilePath}' is ignored by configured ignore patterns.`;
expect(() => tool.build(params)).toThrow(expectedError);
});
+5 -2
View File
@@ -210,8 +210,11 @@ export class ReadFileTool extends BaseDeclarativeTool<
}
const fileService = this.config.getFileService();
if (fileService.shouldGeminiIgnoreFile(params.absolute_path)) {
return `File path '${filePath}' is ignored by .geminiignore pattern(s).`;
const fileFilteringOptions = this.config.getFileFilteringOptions();
if (
fileService.shouldIgnoreFile(params.absolute_path, fileFilteringOptions)
) {
return `File path '${filePath}' is ignored by configured ignore patterns.`;
}
return null;