diff --git a/src/utils/__tests__/git-test-helpers.ts b/src/utils/__tests__/git-test-helpers.ts index 7c0705de..4bce9721 100644 --- a/src/utils/__tests__/git-test-helpers.ts +++ b/src/utils/__tests__/git-test-helpers.ts @@ -4,6 +4,7 @@ export function expectGitExecOptions(options: unknown, cwd?: string): void { expect(options).toEqual(expect.objectContaining({ encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'], + timeout: 5_000, windowsHide: true, ...(cwd ? { cwd } : {}) })); diff --git a/src/utils/git.ts b/src/utils/git.ts index e5714050..e78bb2b7 100644 --- a/src/utils/git.ts +++ b/src/utils/git.ts @@ -38,6 +38,7 @@ interface PersistentGitCache { const DEFAULT_GIT_CACHE_TTL_SECONDS = 5; const GIT_CACHE_SCHEMA_VERSION = 1 as const; +const GIT_COMMAND_TIMEOUT_MS = 5_000; // In-process cache keeps cwd in the key; the persistent cache stores cwd once // at the file level and keys entries by command. @@ -331,6 +332,7 @@ export function runGitArgs(args: string[], context: RenderContext, cacheCommand? encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'], env: { ...process.env, GIT_OPTIONAL_LOCKS: '0' }, + timeout: GIT_COMMAND_TIMEOUT_MS, windowsHide: true, ...(cwd ? { cwd } : {}) }).trimEnd();