mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 02:24:09 -07:00
fix(core): handle checkIsRepo failure in GitService.initialize (#15574)
This commit is contained in:
@@ -60,6 +60,15 @@ vi.mock('os', async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
const hoistedMockDebugLogger = vi.hoisted(() => ({
|
||||
debug: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
}));
|
||||
vi.mock('../utils/debugLogger.js', () => ({
|
||||
debugLogger: hoistedMockDebugLogger,
|
||||
}));
|
||||
|
||||
describe('GitService', () => {
|
||||
let testRootDir: string;
|
||||
let projectRoot: string;
|
||||
@@ -248,6 +257,21 @@ describe('GitService', () => {
|
||||
await service.setupShadowGitRepository();
|
||||
expect(hoistedMockCommit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should handle checkIsRepo failure gracefully and initialize repo', async () => {
|
||||
// Simulate checkIsRepo failing (e.g., on certain Git versions like macOS 2.39.5)
|
||||
hoistedMockCheckIsRepo.mockRejectedValue(
|
||||
new Error('git rev-parse --is-inside-work-tree failed'),
|
||||
);
|
||||
const service = new GitService(projectRoot, storage);
|
||||
await service.setupShadowGitRepository();
|
||||
// Should proceed to initialize the repo since checkIsRepo failed
|
||||
expect(hoistedMockInit).toHaveBeenCalled();
|
||||
// Should log the error using debugLogger
|
||||
expect(hoistedMockDebugLogger.debug).toHaveBeenCalledWith(
|
||||
expect.stringContaining('checkIsRepo failed'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createFileSnapshot', () => {
|
||||
|
||||
Reference in New Issue
Block a user