Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-11-20 20:57:59 -08:00
|
|
|
import {
|
|
|
|
|
afterAll,
|
|
|
|
|
afterEach,
|
|
|
|
|
beforeAll,
|
|
|
|
|
beforeEach,
|
|
|
|
|
describe,
|
|
|
|
|
expect,
|
|
|
|
|
it,
|
|
|
|
|
vi,
|
|
|
|
|
} from 'vitest';
|
2025-08-25 22:11:27 +02:00
|
|
|
import * as fs from 'node:fs';
|
|
|
|
|
import * as path from 'node:path';
|
|
|
|
|
import { tmpdir } from 'node:os';
|
2025-10-17 22:39:53 -07:00
|
|
|
import type { ConfigParameters } from '@google/gemini-cli-core';
|
2025-10-10 12:04:15 -04:00
|
|
|
import {
|
|
|
|
|
Config,
|
|
|
|
|
DEFAULT_FILE_FILTERING_OPTIONS,
|
|
|
|
|
} from '@google/gemini-cli-core';
|
2026-01-15 09:26:10 -08:00
|
|
|
import { createTestMergedSettings } from './settings.js';
|
2025-08-12 14:31:59 -04:00
|
|
|
import { http, HttpResponse } from 'msw';
|
2026-01-15 09:26:10 -08:00
|
|
|
|
2025-08-12 14:31:59 -04:00
|
|
|
import { setupServer } from 'msw/node';
|
|
|
|
|
|
|
|
|
|
export const server = setupServer();
|
|
|
|
|
|
|
|
|
|
// TODO(richieforeman): Consider moving this to test setup globally.
|
|
|
|
|
beforeAll(() => {
|
|
|
|
|
server.listen({});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
server.resetHandlers();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
|
server.close();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const CLEARCUT_URL = 'https://play.googleapis.com/log';
|
2025-06-07 16:17:27 -07:00
|
|
|
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
// Mock file discovery service and tool registry
|
2025-06-25 05:41:11 -07:00
|
|
|
vi.mock('@google/gemini-cli-core', async () => {
|
|
|
|
|
const actual = await vi.importActual('@google/gemini-cli-core');
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
return {
|
|
|
|
|
...actual,
|
|
|
|
|
FileDiscoveryService: vi.fn().mockImplementation(() => ({
|
|
|
|
|
initialize: vi.fn(),
|
|
|
|
|
})),
|
|
|
|
|
createToolRegistry: vi.fn().mockResolvedValue({}),
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Configuration Integration Tests', () => {
|
|
|
|
|
let tempDir: string;
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2025-08-12 14:31:59 -04:00
|
|
|
server.resetHandlers(http.post(CLEARCUT_URL, () => HttpResponse.text()));
|
|
|
|
|
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
tempDir = fs.mkdtempSync(path.join(tmpdir(), 'gemini-cli-test-'));
|
2025-08-17 12:43:21 -04:00
|
|
|
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
vi.clearAllMocks();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
2025-08-17 12:43:21 -04:00
|
|
|
vi.unstubAllEnvs();
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
if (fs.existsSync(tempDir)) {
|
|
|
|
|
fs.rmSync(tempDir, { recursive: true });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-11-20 20:57:59 -08:00
|
|
|
describe('File Filtering and Configuration', () => {
|
|
|
|
|
it.each([
|
|
|
|
|
{
|
|
|
|
|
description:
|
|
|
|
|
'should load default file filtering settings when fileFiltering is missing',
|
|
|
|
|
fileFiltering: undefined,
|
|
|
|
|
expected: DEFAULT_FILE_FILTERING_OPTIONS.respectGitIgnore,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
description:
|
|
|
|
|
'should load custom file filtering settings from configuration',
|
|
|
|
|
fileFiltering: { respectGitIgnore: false },
|
|
|
|
|
expected: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
description:
|
|
|
|
|
'should respect file filtering settings from configuration',
|
|
|
|
|
fileFiltering: { respectGitIgnore: true },
|
|
|
|
|
expected: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
description:
|
|
|
|
|
'should handle empty fileFiltering object gracefully and use defaults',
|
2025-10-10 12:04:15 -04:00
|
|
|
fileFiltering: {},
|
2025-11-20 20:57:59 -08:00
|
|
|
expected: DEFAULT_FILE_FILTERING_OPTIONS.respectGitIgnore,
|
|
|
|
|
},
|
|
|
|
|
])('$description', async ({ fileFiltering, expected }) => {
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
const configParams: ConfigParameters = {
|
2025-10-17 22:39:53 -07:00
|
|
|
sessionId: 'test-session',
|
2025-06-12 17:17:29 -07:00
|
|
|
cwd: '/tmp',
|
2025-10-17 22:39:53 -07:00
|
|
|
model: 'test-model',
|
2025-06-07 16:17:27 -07:00
|
|
|
embeddingModel: 'test-embedding-model',
|
2025-10-17 22:39:53 -07:00
|
|
|
sandbox: undefined,
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
targetDir: tempDir,
|
|
|
|
|
debugMode: false,
|
2025-11-20 20:57:59 -08:00
|
|
|
fileFiltering,
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const config = new Config(configParams);
|
|
|
|
|
|
2025-11-20 20:57:59 -08:00
|
|
|
expect(config.getFileFilteringRespectGitIgnore()).toBe(expected);
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Real-world Configuration Scenarios', () => {
|
2025-11-20 20:57:59 -08:00
|
|
|
it.each([
|
|
|
|
|
{
|
|
|
|
|
description: 'should handle a security-focused configuration',
|
|
|
|
|
respectGitIgnore: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
description: 'should handle a CI/CD environment configuration',
|
|
|
|
|
respectGitIgnore: false,
|
|
|
|
|
},
|
|
|
|
|
])('$description', async ({ respectGitIgnore }) => {
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
const configParams: ConfigParameters = {
|
2025-10-17 22:39:53 -07:00
|
|
|
sessionId: 'test-session',
|
2025-06-12 17:17:29 -07:00
|
|
|
cwd: '/tmp',
|
2025-10-17 22:39:53 -07:00
|
|
|
model: 'test-model',
|
2025-06-07 16:17:27 -07:00
|
|
|
embeddingModel: 'test-embedding-model',
|
2025-10-17 22:39:53 -07:00
|
|
|
sandbox: undefined,
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
targetDir: tempDir,
|
|
|
|
|
debugMode: false,
|
2025-10-10 12:04:15 -04:00
|
|
|
fileFiltering: {
|
2025-11-20 20:57:59 -08:00
|
|
|
respectGitIgnore,
|
2025-10-10 12:04:15 -04:00
|
|
|
},
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const config = new Config(configParams);
|
|
|
|
|
|
2025-11-20 20:57:59 -08:00
|
|
|
expect(config.getFileFilteringRespectGitIgnore()).toBe(respectGitIgnore);
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
});
|
|
|
|
|
});
|
2025-06-20 00:39:15 -04:00
|
|
|
|
|
|
|
|
describe('Checkpointing Configuration', () => {
|
|
|
|
|
it('should enable checkpointing when the setting is true', async () => {
|
|
|
|
|
const configParams: ConfigParameters = {
|
2025-10-17 22:39:53 -07:00
|
|
|
sessionId: 'test-session',
|
2025-06-20 00:39:15 -04:00
|
|
|
cwd: '/tmp',
|
2025-10-17 22:39:53 -07:00
|
|
|
model: 'test-model',
|
2025-06-20 00:39:15 -04:00
|
|
|
embeddingModel: 'test-embedding-model',
|
2025-10-17 22:39:53 -07:00
|
|
|
sandbox: undefined,
|
2025-06-20 00:39:15 -04:00
|
|
|
targetDir: tempDir,
|
|
|
|
|
debugMode: false,
|
|
|
|
|
checkpointing: true,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const config = new Config(configParams);
|
|
|
|
|
|
|
|
|
|
expect(config.getCheckpointingEnabled()).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
});
|
2025-06-22 16:17:05 -07:00
|
|
|
|
2025-08-12 15:10:22 -07:00
|
|
|
describe('Approval Mode Integration Tests', () => {
|
2025-10-17 22:39:53 -07:00
|
|
|
let parseArguments: typeof import('./config.js').parseArguments;
|
2025-08-12 15:10:22 -07:00
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
// Import the argument parsing function for integration testing
|
2025-10-17 22:39:53 -07:00
|
|
|
const { parseArguments: parseArgs } = await import('./config.js');
|
2025-08-12 15:10:22 -07:00
|
|
|
parseArguments = parseArgs;
|
|
|
|
|
});
|
|
|
|
|
|
2025-11-20 20:57:59 -08:00
|
|
|
it.each([
|
|
|
|
|
{
|
|
|
|
|
description: 'should parse --approval-mode=auto_edit correctly',
|
|
|
|
|
argv: [
|
2025-08-12 15:10:22 -07:00
|
|
|
'node',
|
|
|
|
|
'script.js',
|
|
|
|
|
'--approval-mode',
|
|
|
|
|
'auto_edit',
|
|
|
|
|
'-p',
|
|
|
|
|
'test',
|
2025-11-20 20:57:59 -08:00
|
|
|
],
|
|
|
|
|
expected: { approvalMode: 'auto_edit', prompt: 'test', yolo: false },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
description: 'should parse --approval-mode=yolo correctly',
|
|
|
|
|
argv: ['node', 'script.js', '--approval-mode', 'yolo', '-p', 'test'],
|
|
|
|
|
expected: { approvalMode: 'yolo', prompt: 'test', yolo: false },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
description: 'should parse --approval-mode=default correctly',
|
|
|
|
|
argv: ['node', 'script.js', '--approval-mode', 'default', '-p', 'test'],
|
|
|
|
|
expected: { approvalMode: 'default', prompt: 'test', yolo: false },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
description: 'should parse legacy --yolo flag correctly',
|
|
|
|
|
argv: ['node', 'script.js', '--yolo', '-p', 'test'],
|
|
|
|
|
expected: { yolo: true, approvalMode: undefined, prompt: 'test' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
description: 'should handle no approval mode arguments',
|
|
|
|
|
argv: ['node', 'script.js', '-p', 'test'],
|
|
|
|
|
expected: { approvalMode: undefined, yolo: false, prompt: 'test' },
|
|
|
|
|
},
|
|
|
|
|
])('$description', async ({ argv, expected }) => {
|
2025-08-12 15:10:22 -07:00
|
|
|
const originalArgv = process.argv;
|
|
|
|
|
try {
|
2025-11-20 20:57:59 -08:00
|
|
|
process.argv = argv;
|
2026-01-15 09:26:10 -08:00
|
|
|
const parsedArgs = await parseArguments(createTestMergedSettings());
|
2025-11-20 20:57:59 -08:00
|
|
|
expect(parsedArgs.approvalMode).toBe(expected.approvalMode);
|
|
|
|
|
expect(parsedArgs.prompt).toBe(expected.prompt);
|
|
|
|
|
expect(parsedArgs.yolo).toBe(expected.yolo);
|
2025-08-12 15:10:22 -07:00
|
|
|
} finally {
|
|
|
|
|
process.argv = originalArgv;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-11-20 20:57:59 -08:00
|
|
|
it.each([
|
|
|
|
|
{
|
|
|
|
|
description: 'should reject invalid approval mode values',
|
|
|
|
|
argv: ['node', 'script.js', '--approval-mode', 'invalid_mode'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
description:
|
|
|
|
|
'should reject conflicting --yolo and --approval-mode flags',
|
|
|
|
|
argv: ['node', 'script.js', '--yolo', '--approval-mode', 'default'],
|
|
|
|
|
},
|
|
|
|
|
])('$description', async ({ argv }) => {
|
2025-08-12 15:10:22 -07:00
|
|
|
const originalArgv = process.argv;
|
|
|
|
|
try {
|
2025-11-20 20:57:59 -08:00
|
|
|
process.argv = argv;
|
2026-01-15 09:26:10 -08:00
|
|
|
await expect(
|
|
|
|
|
parseArguments(createTestMergedSettings()),
|
|
|
|
|
).rejects.toThrow();
|
2025-08-12 15:10:22 -07:00
|
|
|
} finally {
|
|
|
|
|
process.argv = originalArgv;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli
This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.
Key Improvements
.gitignore File Filtering
All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates
settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing
New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring
Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-03 21:40:46 -07:00
|
|
|
});
|