mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-28 05:55:17 -07:00
refactor: Switch over to unified shouldIgnoreFile (#11815)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user