mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-15 16:41:11 -07:00
fix(core): ripgrep fails when pattern looks like ripgrep flag (#18858)
Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
@@ -1430,11 +1430,15 @@ describe('RipGrepTool', () => {
|
||||
});
|
||||
const result = await invocation.execute(abortSignal);
|
||||
|
||||
expect(mockSpawn).toHaveBeenLastCalledWith(
|
||||
expect.anything(),
|
||||
expect.arrayContaining(['--fixed-strings']),
|
||||
expect.anything(),
|
||||
);
|
||||
const spawnArgs = mockSpawn.mock.calls[0][1];
|
||||
expect(spawnArgs).toContain('--fixed-strings');
|
||||
expect(spawnArgs).toContain('--regexp');
|
||||
expect(spawnArgs).toContain('hello.world');
|
||||
|
||||
// Verify --fixed-strings doesn't have the pattern as its next argument
|
||||
const fixedStringsIdx = spawnArgs.indexOf('--fixed-strings');
|
||||
expect(spawnArgs[fixedStringsIdx + 1]).not.toBe('hello.world');
|
||||
|
||||
expect(result.llmContent).toContain(
|
||||
'Found 1 match for pattern "hello.world"',
|
||||
);
|
||||
|
||||
@@ -387,11 +387,10 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
|
||||
if (fixed_strings) {
|
||||
rgArgs.push('--fixed-strings');
|
||||
rgArgs.push(pattern);
|
||||
} else {
|
||||
rgArgs.push('--regexp', pattern);
|
||||
}
|
||||
|
||||
rgArgs.push('--regexp', pattern);
|
||||
|
||||
if (context) {
|
||||
rgArgs.push('--context', context.toString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user