fix(core): use GIT_CONFIG_GLOBAL to isolate shadow git repo configuration - Fixes #17877 (#17803)

This commit is contained in:
Coco Sheng
2026-01-29 14:08:34 -05:00
committed by GitHub
parent bc258eba4c
commit bcc6ee596a
3 changed files with 188 additions and 4 deletions

View File

@@ -283,6 +283,25 @@ describe('GitService', () => {
expect.stringContaining('checkIsRepo failed'),
);
});
it('should configure git environment to use local gitconfig', async () => {
hoistedMockCheckIsRepo.mockResolvedValue(false);
const service = new GitService(projectRoot, storage);
await service.setupShadowGitRepository();
expect(hoistedMockEnv).toHaveBeenCalledWith(
expect.objectContaining({
GIT_CONFIG_GLOBAL: gitConfigPath,
GIT_CONFIG_SYSTEM: path.join(repoDir, '.gitconfig_system_empty'),
}),
);
const systemConfigContent = await fs.readFile(
path.join(repoDir, '.gitconfig_system_empty'),
'utf-8',
);
expect(systemConfigContent).toBe('');
});
});
describe('createFileSnapshot', () => {