(
input: CloneProjectParams
)
| 530 | } |
| 531 | |
| 532 | private validateAndPrepareClone( |
| 533 | input: CloneProjectParams |
| 534 | ): Result<{ cloneUrl: string; normalizedPath: string; cloneParentDir: string }> { |
| 535 | try { |
| 536 | const repoUrl = input.repoUrl.trim(); |
| 537 | if (!repoUrl) { |
| 538 | return Err("Repository URL cannot be empty"); |
| 539 | } |
| 540 | |
| 541 | const config = this.config.loadConfigOrDefault(); |
| 542 | const cloneParentDir = resolveProjectParentDir( |
| 543 | input.cloneParentDir, |
| 544 | config.defaultProjectDir |
| 545 | ); |
| 546 | const repoFolderName = deriveRepoFolderName(repoUrl); |
| 547 | const normalizedPath = path.join(cloneParentDir, repoFolderName); |
| 548 | |
| 549 | const normalizedProjects = deriveProjectHierarchy(config.projects); |
| 550 | if (findDeepestTopLevelParentProject(normalizedPath, normalizedProjects)) { |
| 551 | return Err("Cannot clone a new git repository inside an existing project tree"); |
| 552 | } |
| 553 | |
| 554 | if (config.projects.has(normalizedPath)) { |
| 555 | return Err(`Project already exists at ${normalizedPath}`); |
| 556 | } |
| 557 | |
| 558 | return Ok({ |
| 559 | cloneUrl: normalizeRepoUrlForClone(repoUrl), |
| 560 | normalizedPath, |
| 561 | cloneParentDir, |
| 562 | }); |
| 563 | } catch (error) { |
| 564 | const message = getErrorMessage(error); |
| 565 | return Err(message); |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | async *cloneWithProgress( |
| 570 | input: CloneProjectParams, |
no test coverage detected