* Executes a git command with retry logic and exponential backoff
( command: string, args: string[], options: any, maxRetries: number = 3, baseDelay: number = 1000, )
| 39 | * Executes a git command with retry logic and exponential backoff |
| 40 | */ |
| 41 | async function executeGitCommandWithRetry( |
| 42 | command: string, |
| 43 | args: string[], |
| 44 | options: any, |
| 45 | maxRetries: number = 3, |
| 46 | baseDelay: number = 1000, |
| 47 | ): Promise<void> { |
| 48 | let lastError: Error | undefined |
| 49 | |
| 50 | for (let attempt = 0; attempt < maxRetries; attempt++) { |
| 51 | try { |
| 52 | execFileSync(command, args, options) |
| 53 | return // Success! |
| 54 | } catch (error) { |
| 55 | lastError = error as Error |
| 56 | |
| 57 | if (attempt < maxRetries - 1) { |
| 58 | const delay = baseDelay * Math.pow(2, attempt) |
| 59 | console.warn( |
| 60 | `Git command failed (attempt ${attempt + 1}/${maxRetries}): ${error instanceof Error ? error.message : String(error)}`, |
| 61 | ) |
| 62 | console.warn(`Retrying in ${delay}ms...`) |
| 63 | await new Promise((resolve) => setTimeout(resolve, delay)) |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | throw lastError || new Error('Git command failed after all retries') |
| 69 | } |
| 70 | |
| 71 | export async function setupTestRepo( |
| 72 | repoUrl: string, |
no test coverage detected