( error: unknown, targetPath: string )
| 85 | } |
| 86 | |
| 87 | export function classifyCloneRepositoryError( |
| 88 | error: unknown, |
| 89 | targetPath: string |
| 90 | ): CloneRepositoryError { |
| 91 | const commandError = toGitCommandError(error); |
| 92 | const message = commandError.message.toLowerCase(); |
| 93 | if ( |
| 94 | message.includes('already exists and is not an empty directory') || |
| 95 | (message.includes('destination path') && message.includes('already exists')) |
| 96 | ) { |
| 97 | return { type: 'target_exists', path: targetPath, message: commandError.message }; |
| 98 | } |
| 99 | if (message.includes('authentication') || message.includes('permission denied')) { |
| 100 | return { type: 'auth_failed', message: commandError.message }; |
| 101 | } |
| 102 | if ( |
| 103 | message.includes('repository not found') || |
| 104 | message.includes('does not appear to be a git repository') || |
| 105 | message.includes('not found') |
| 106 | ) { |
| 107 | return { type: 'remote_not_found', message: commandError.message }; |
| 108 | } |
| 109 | return commandError; |
| 110 | } |
| 111 | |
| 112 | export function classifyFetchError(error: unknown, remote: string | undefined): FetchError { |
| 113 | const commandError = toGitCommandError(error); |
no test coverage detected