mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(core): Preserve significant trailing spaces in gitignore patterns (#11536)
This commit is contained in:
@@ -250,4 +250,24 @@ src/*.tmp
|
||||
expect(parser.isIgnored('bla/!bar')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Trailing Spaces', () => {
|
||||
beforeEach(async () => {
|
||||
await setupGitRepo();
|
||||
});
|
||||
|
||||
it('should correctly handle significant trailing spaces', async () => {
|
||||
await createTestFile('.gitignore', 'foo\\ \nbar ');
|
||||
await createTestFile('foo ', 'content');
|
||||
await createTestFile('bar', 'content');
|
||||
await createTestFile('bar ', 'content');
|
||||
|
||||
// 'foo\ ' should match 'foo '
|
||||
expect(parser.isIgnored('foo ')).toBe(true);
|
||||
|
||||
// 'bar ' should be trimmed to 'bar'
|
||||
expect(parser.isIgnored('bar')).toBe(true);
|
||||
expect(parser.isIgnored('bar ')).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@ export class GitIgnoreParser implements GitIgnoreFilter {
|
||||
|
||||
return content
|
||||
.split('\n')
|
||||
.map((p) => p.trim())
|
||||
.map((p) => p.trimStart())
|
||||
.filter((p) => p !== '' && !p.startsWith('#'))
|
||||
.map((p) => {
|
||||
const isNegative = p.startsWith('!');
|
||||
|
||||
Reference in New Issue
Block a user