mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
refactor: Switch over to unified shouldIgnoreFile (#11815)
This commit is contained in:
@@ -12,6 +12,7 @@ import type {
|
||||
ToolResult,
|
||||
ToolCallConfirmationDetails,
|
||||
GeminiCLIExtension,
|
||||
FilterFilesOptions,
|
||||
} from '@google/gemini-cli-core';
|
||||
import {
|
||||
AuthType,
|
||||
@@ -571,7 +572,8 @@ class Session {
|
||||
|
||||
// Get centralized file discovery service
|
||||
const fileDiscovery = this.config.getFileService();
|
||||
const respectGitIgnore = this.config.getFileFilteringRespectGitIgnore();
|
||||
const fileFilteringOptions: FilterFilesOptions =
|
||||
this.config.getFileFilteringOptions();
|
||||
|
||||
const pathSpecsToRead: string[] = [];
|
||||
const contentLabelsForDisplay: string[] = [];
|
||||
@@ -587,13 +589,10 @@ class Session {
|
||||
|
||||
for (const atPathPart of atPathCommandParts) {
|
||||
const pathName = atPathPart.fileData!.fileUri;
|
||||
// Check if path should be ignored by git
|
||||
if (fileDiscovery.shouldGitIgnoreFile(pathName)) {
|
||||
// Check if path should be ignored
|
||||
if (fileDiscovery.shouldIgnoreFile(pathName, fileFilteringOptions)) {
|
||||
ignoredPaths.push(pathName);
|
||||
const reason = respectGitIgnore
|
||||
? 'git-ignored and will be skipped'
|
||||
: 'ignored by custom patterns';
|
||||
debugLogger.warn(`Path ${pathName} is ${reason}.`);
|
||||
debugLogger.warn(`Path ${pathName} is ignored and will be skipped.`);
|
||||
continue;
|
||||
}
|
||||
let currentPathSpec = pathName;
|
||||
@@ -730,9 +729,8 @@ class Session {
|
||||
initialQueryText = initialQueryText.trim();
|
||||
// Inform user about ignored paths
|
||||
if (ignoredPaths.length > 0) {
|
||||
const ignoreType = respectGitIgnore ? 'git-ignored' : 'custom-ignored';
|
||||
this.debug(
|
||||
`Ignored ${ignoredPaths.length} ${ignoreType} files: ${ignoredPaths.join(', ')}`,
|
||||
`Ignored ${ignoredPaths.length} files: ${ignoredPaths.join(', ')}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -747,7 +745,6 @@ class Session {
|
||||
if (pathSpecsToRead.length > 0) {
|
||||
const toolArgs = {
|
||||
paths: pathSpecsToRead,
|
||||
respectGitIgnore, // Use configuration setting
|
||||
};
|
||||
|
||||
const callId = `${readManyFilesTool.name}-${Date.now()}`;
|
||||
|
||||
Reference in New Issue
Block a user