mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-25 21:41:12 -07:00
Add support for an additional exclusion file besides .gitignore and .geminiignore (#16487)
Co-authored-by: Adam Weidman <adamfweidman@google.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
StandardFileSystemService,
|
||||
ToolRegistry,
|
||||
COMMON_IGNORE_PATTERNS,
|
||||
GEMINI_IGNORE_FILE_NAME,
|
||||
// DEFAULT_FILE_EXCLUDES,
|
||||
} from '@google/gemini-cli-core';
|
||||
import * as core from '@google/gemini-cli-core';
|
||||
@@ -628,7 +629,7 @@ describe('handleAtCommand', () => {
|
||||
describe('gemini-ignore filtering', () => {
|
||||
it('should skip gemini-ignored files in @ commands', async () => {
|
||||
await createTestFile(
|
||||
path.join(testRootDir, '.geminiignore'),
|
||||
path.join(testRootDir, GEMINI_IGNORE_FILE_NAME),
|
||||
'build/output.js',
|
||||
);
|
||||
const geminiIgnoredFile = await createTestFile(
|
||||
@@ -659,7 +660,7 @@ describe('handleAtCommand', () => {
|
||||
});
|
||||
it('should process non-ignored files when .geminiignore is present', async () => {
|
||||
await createTestFile(
|
||||
path.join(testRootDir, '.geminiignore'),
|
||||
path.join(testRootDir, GEMINI_IGNORE_FILE_NAME),
|
||||
'build/output.js',
|
||||
);
|
||||
const validFile = await createTestFile(
|
||||
@@ -690,7 +691,7 @@ describe('handleAtCommand', () => {
|
||||
|
||||
it('should handle mixed gemini-ignored and valid files', async () => {
|
||||
await createTestFile(
|
||||
path.join(testRootDir, '.geminiignore'),
|
||||
path.join(testRootDir, GEMINI_IGNORE_FILE_NAME),
|
||||
'dist/bundle.js',
|
||||
);
|
||||
const validFile = await createTestFile(
|
||||
|
||||
@@ -10,7 +10,10 @@ import { renderHook } from '../../test-utils/render.js';
|
||||
import { waitFor } from '../../test-utils/async.js';
|
||||
import { useAtCompletion } from './useAtCompletion.js';
|
||||
import type { Config, FileSearch } from '@google/gemini-cli-core';
|
||||
import { FileSearchFactory } from '@google/gemini-cli-core';
|
||||
import {
|
||||
FileSearchFactory,
|
||||
FileDiscoveryService,
|
||||
} from '@google/gemini-cli-core';
|
||||
import type { FileSystemStructure } from '@google/gemini-cli-test-utils';
|
||||
import { createTmpDir, cleanupTmpDir } from '@google/gemini-cli-test-utils';
|
||||
import type { Suggestion } from '../components/SuggestionsDisplay.js';
|
||||
@@ -148,8 +151,10 @@ describe('useAtCompletion', () => {
|
||||
const fileSearch = FileSearchFactory.create({
|
||||
projectRoot: testRootDir,
|
||||
ignoreDirs: [],
|
||||
useGitignore: false,
|
||||
useGeminiignore: false,
|
||||
fileDiscoveryService: new FileDiscoveryService(testRootDir, {
|
||||
respectGitIgnore: false,
|
||||
respectGeminiIgnore: false,
|
||||
}),
|
||||
cache: false,
|
||||
cacheTtl: 0,
|
||||
enableRecursiveFileSearch: true,
|
||||
@@ -271,8 +276,10 @@ describe('useAtCompletion', () => {
|
||||
const realFileSearch = FileSearchFactory.create({
|
||||
projectRoot: testRootDir,
|
||||
ignoreDirs: [],
|
||||
useGitignore: true,
|
||||
useGeminiignore: true,
|
||||
fileDiscoveryService: new FileDiscoveryService(testRootDir, {
|
||||
respectGitIgnore: true,
|
||||
respectGeminiIgnore: true,
|
||||
}),
|
||||
cache: false,
|
||||
cacheTtl: 0,
|
||||
enableRecursiveFileSearch: true,
|
||||
|
||||
@@ -7,7 +7,11 @@
|
||||
import { useEffect, useReducer, useRef } from 'react';
|
||||
import { setTimeout as setTimeoutPromise } from 'node:timers/promises';
|
||||
import type { Config, FileSearch } from '@google/gemini-cli-core';
|
||||
import { FileSearchFactory, escapePath } from '@google/gemini-cli-core';
|
||||
import {
|
||||
FileSearchFactory,
|
||||
escapePath,
|
||||
FileDiscoveryService,
|
||||
} from '@google/gemini-cli-core';
|
||||
import type { Suggestion } from '../components/SuggestionsDisplay.js';
|
||||
import { MAX_SUGGESTIONS_TO_SHOW } from '../components/SuggestionsDisplay.js';
|
||||
import { CommandKind } from '../commands/types.js';
|
||||
@@ -250,10 +254,10 @@ export function useAtCompletion(props: UseAtCompletionProps): void {
|
||||
const searcher = FileSearchFactory.create({
|
||||
projectRoot: cwd,
|
||||
ignoreDirs: [],
|
||||
useGitignore:
|
||||
config?.getFileFilteringOptions()?.respectGitIgnore ?? true,
|
||||
useGeminiignore:
|
||||
config?.getFileFilteringOptions()?.respectGeminiIgnore ?? true,
|
||||
fileDiscoveryService: new FileDiscoveryService(
|
||||
cwd,
|
||||
config?.getFileFilteringOptions(),
|
||||
),
|
||||
cache: true,
|
||||
cacheTtl: 30, // 30 seconds
|
||||
enableRecursiveFileSearch:
|
||||
|
||||
Reference in New Issue
Block a user