fix: initialisation of git

This commit is contained in:
2026-02-16 11:23:10 +01:00
parent 0230010515
commit 4695570c34
6 changed files with 109 additions and 0 deletions

View File

@@ -350,4 +350,36 @@ describe('GitEngine', () => {
expect(result.error).toContain('install Git LFS');
});
});
describe('pruneLfsCache', () => {
it('should run git lfs prune with verify-remote by default', async () => {
mockRaw.mockResolvedValue('prune complete');
const result = await gitEngine.pruneLfsCache('/tmp/project');
expect(mockRaw).toHaveBeenCalledWith(['lfs', 'prune', '--verify-remote']);
expect(result.success).toBe(true);
expect(result.dryRun).toBe(false);
expect(result.verifyRemote).toBe(true);
});
it('should run git lfs prune in dry-run mode when requested', async () => {
mockRaw.mockResolvedValue('would prune');
const result = await gitEngine.pruneLfsCache('/tmp/project', { dryRun: true });
expect(mockRaw).toHaveBeenCalledWith(['lfs', 'prune', '--verify-remote', '--dry-run']);
expect(result.success).toBe(true);
expect(result.dryRun).toBe(true);
});
it('should return error result when git lfs prune fails', async () => {
mockRaw.mockRejectedValue(new Error('prune failed'));
const result = await gitEngine.pruneLfsCache('/tmp/project');
expect(result.success).toBe(false);
expect(result.error).toContain('prune failed');
});
});
});

View File

@@ -146,6 +146,7 @@ const mockGitEngine = {
getStatus: vi.fn(),
initializeRepo: vi.fn(),
ensureGitignore: vi.fn(),
pruneLfsCache: vi.fn(),
};
const mockTaskManager = {
@@ -379,6 +380,22 @@ describe('IPC Handlers', () => {
});
});
});
describe('git:pruneLfs', () => {
it('should pass project path and options to GitEngine.pruneLfsCache', async () => {
mockGitEngine.pruneLfsCache.mockResolvedValue({
success: true,
dryRun: true,
verifyRemote: true,
output: 'would prune',
});
const result = await invokeHandler('git:pruneLfs', '/repo', { dryRun: true, verifyRemote: true });
expect(mockGitEngine.pruneLfsCache).toHaveBeenCalledWith('/repo', { dryRun: true, verifyRemote: true });
expect(result.success).toBe(true);
});
});
});
// ============ Project Handlers ============