[A2A] Disable checkpointing if git is not installed (#16896)

This commit is contained in:
Coco Sheng
2026-01-20 11:38:38 -05:00
committed by GitHub
parent 166e04a8dd
commit 79076d1d52
5 changed files with 133 additions and 10 deletions

View File

@@ -147,15 +147,13 @@ describe('GitService', () => {
describe('verifyGitAvailability', () => {
it('should resolve true if git --version command succeeds', async () => {
const service = new GitService(projectRoot, storage);
await expect(service.verifyGitAvailability()).resolves.toBe(true);
await expect(GitService.verifyGitAvailability()).resolves.toBe(true);
expect(spawnAsync).toHaveBeenCalledWith('git', ['--version']);
});
it('should resolve false if git --version command fails', async () => {
(spawnAsync as Mock).mockRejectedValue(new Error('git not found'));
const service = new GitService(projectRoot, storage);
await expect(service.verifyGitAvailability()).resolves.toBe(false);
await expect(GitService.verifyGitAvailability()).resolves.toBe(false);
});
});

View File

@@ -27,7 +27,7 @@ export class GitService {
}
async initialize(): Promise<void> {
const gitAvailable = await this.verifyGitAvailability();
const gitAvailable = await GitService.verifyGitAvailability();
if (!gitAvailable) {
throw new Error(
'Checkpointing is enabled, but Git is not installed. Please install Git or disable checkpointing to continue.',
@@ -42,7 +42,7 @@ export class GitService {
}
}
async verifyGitAvailability(): Promise<boolean> {
static async verifyGitAvailability(): Promise<boolean> {
try {
await spawnAsync('git', ['--version']);
return true;