mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 13:04:49 -07:00
refactor: Switch over to unified shouldIgnoreFile (#11815)
This commit is contained in:
@@ -8,7 +8,10 @@ import * as fs from 'node:fs/promises';
|
||||
import type { Dirent } from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { getErrorMessage, isNodeError } from './errors.js';
|
||||
import type { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
||||
import type {
|
||||
FileDiscoveryService,
|
||||
FilterFilesOptions,
|
||||
} from '../services/fileDiscoveryService.js';
|
||||
import type { FileFilteringOptions } from '../config/constants.js';
|
||||
import { DEFAULT_FILE_FILTERING_OPTIONS } from '../config/constants.js';
|
||||
import { debugLogger } from './debugLogger.js';
|
||||
@@ -119,6 +122,10 @@ async function readFullStructure(
|
||||
|
||||
const filesInCurrentDir: string[] = [];
|
||||
const subFoldersInCurrentDir: FullFolderInfo[] = [];
|
||||
const filterFileOptions: FilterFilesOptions = {
|
||||
respectGitIgnore: options.fileFilteringOptions?.respectGitIgnore,
|
||||
respectGeminiIgnore: options.fileFilteringOptions?.respectGeminiIgnore,
|
||||
};
|
||||
|
||||
// Process files first in the current directory
|
||||
for (const entry of entries) {
|
||||
@@ -129,15 +136,10 @@ async function readFullStructure(
|
||||
}
|
||||
const fileName = entry.name;
|
||||
const filePath = path.join(currentPath, fileName);
|
||||
if (options.fileService) {
|
||||
const shouldIgnore =
|
||||
(options.fileFilteringOptions.respectGitIgnore &&
|
||||
options.fileService.shouldGitIgnoreFile(filePath)) ||
|
||||
(options.fileFilteringOptions.respectGeminiIgnore &&
|
||||
options.fileService.shouldGeminiIgnoreFile(filePath));
|
||||
if (shouldIgnore) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
options.fileService?.shouldIgnoreFile(filePath, filterFileOptions)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
!options.fileIncludePattern ||
|
||||
@@ -168,14 +170,11 @@ async function readFullStructure(
|
||||
const subFolderName = entry.name;
|
||||
const subFolderPath = path.join(currentPath, subFolderName);
|
||||
|
||||
let isIgnored = false;
|
||||
if (options.fileService) {
|
||||
isIgnored =
|
||||
(options.fileFilteringOptions.respectGitIgnore &&
|
||||
options.fileService.shouldGitIgnoreFile(subFolderPath)) ||
|
||||
(options.fileFilteringOptions.respectGeminiIgnore &&
|
||||
options.fileService.shouldGeminiIgnoreFile(subFolderPath));
|
||||
}
|
||||
const isIgnored =
|
||||
options.fileService?.shouldIgnoreFile(
|
||||
subFolderPath,
|
||||
filterFileOptions,
|
||||
) ?? false;
|
||||
|
||||
if (options.ignoredFolders.has(subFolderName) || isIgnored) {
|
||||
const ignoredSubFolder: FullFolderInfo = {
|
||||
|
||||
Reference in New Issue
Block a user