(repo: string, localPath: string)
| 176 | * subsequent pull/push operations work (see cloneUrl). |
| 177 | */ |
| 178 | export function gitcodeRepoClone(repo: string, localPath: string): void { |
| 179 | const token = getGitCodeToken(); |
| 180 | const result = spawnSync('git', ['clone', cloneUrl(repo, token), localPath], { |
| 181 | encoding: 'utf-8', |
| 182 | stdio: ['pipe', 'pipe', 'pipe'], |
| 183 | timeout: 120_000, |
| 184 | }); |
| 185 | const allOutput = `${result.stderr ?? ''} ${result.stdout ?? ''}`; |
| 186 | if (result.status === 0) return; |
| 187 | |
| 188 | if ( |
| 189 | allOutput.includes('not found') |
| 190 | || allOutput.includes('does not exist') |
| 191 | || allOutput.includes('Repository not found') |
| 192 | || allOutput.includes('could not be found') |
| 193 | || /\b404\b/.test(allOutput) |
| 194 | ) { |
| 195 | throw new GitCodeRepoNotFoundError(repo); |
| 196 | } |
| 197 | |
| 198 | throw new Error(`git clone failed: ${redactCloneOutput(allOutput)}`); |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Create a private GitCode repo. Uses the authenticated user's namespace when |
no test coverage detected