mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -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);
|
const result = await invocation.execute(abortSignal);
|
||||||
|
|
||||||
expect(mockSpawn).toHaveBeenLastCalledWith(
|
const spawnArgs = mockSpawn.mock.calls[0][1];
|
||||||
expect.anything(),
|
expect(spawnArgs).toContain('--fixed-strings');
|
||||||
expect.arrayContaining(['--fixed-strings']),
|
expect(spawnArgs).toContain('--regexp');
|
||||||
expect.anything(),
|
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(
|
expect(result.llmContent).toContain(
|
||||||
'Found 1 match for pattern "hello.world"',
|
'Found 1 match for pattern "hello.world"',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -387,11 +387,10 @@ class GrepToolInvocation extends BaseToolInvocation<
|
|||||||
|
|
||||||
if (fixed_strings) {
|
if (fixed_strings) {
|
||||||
rgArgs.push('--fixed-strings');
|
rgArgs.push('--fixed-strings');
|
||||||
rgArgs.push(pattern);
|
|
||||||
} else {
|
|
||||||
rgArgs.push('--regexp', pattern);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rgArgs.push('--regexp', pattern);
|
||||||
|
|
||||||
if (context) {
|
if (context) {
|
||||||
rgArgs.push('--context', context.toString());
|
rgArgs.push('--context', context.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user