mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-20 19:11:23 -07:00
fix: gitignore handling (#8177)
This commit is contained in:
@@ -5,12 +5,12 @@
|
||||
*/
|
||||
|
||||
import type { GitIgnoreFilter } from '../utils/gitIgnoreParser.js';
|
||||
import type { GeminiIgnoreFilter } from '../utils/geminiIgnoreParser.js';
|
||||
import { GitIgnoreParser } from '../utils/gitIgnoreParser.js';
|
||||
import { GeminiIgnoreParser } from '../utils/geminiIgnoreParser.js';
|
||||
import { isGitRepository } from '../utils/gitUtils.js';
|
||||
import * as path from 'node:path';
|
||||
|
||||
const GEMINI_IGNORE_FILE_NAME = '.geminiignore';
|
||||
|
||||
export interface FilterFilesOptions {
|
||||
respectGitIgnore?: boolean;
|
||||
respectGeminiIgnore?: boolean;
|
||||
@@ -24,27 +24,15 @@ export interface FilterReport {
|
||||
|
||||
export class FileDiscoveryService {
|
||||
private gitIgnoreFilter: GitIgnoreFilter | null = null;
|
||||
private geminiIgnoreFilter: GitIgnoreFilter | null = null;
|
||||
private geminiIgnoreFilter: GeminiIgnoreFilter | null = null;
|
||||
private projectRoot: string;
|
||||
|
||||
constructor(projectRoot: string) {
|
||||
this.projectRoot = path.resolve(projectRoot);
|
||||
if (isGitRepository(this.projectRoot)) {
|
||||
const parser = new GitIgnoreParser(this.projectRoot);
|
||||
try {
|
||||
parser.loadGitRepoPatterns();
|
||||
} catch (_error) {
|
||||
// ignore file not found
|
||||
}
|
||||
this.gitIgnoreFilter = parser;
|
||||
this.gitIgnoreFilter = new GitIgnoreParser(this.projectRoot);
|
||||
}
|
||||
const gParser = new GitIgnoreParser(this.projectRoot);
|
||||
try {
|
||||
gParser.loadPatterns(GEMINI_IGNORE_FILE_NAME);
|
||||
} catch (_error) {
|
||||
// ignore file not found
|
||||
}
|
||||
this.geminiIgnoreFilter = gParser;
|
||||
this.geminiIgnoreFilter = new GeminiIgnoreParser(this.projectRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user