(
projectPath: string,
workspacePath: string,
abortSignal?: AbortSignal
)
| 1452 | } |
| 1453 | |
| 1454 | private async resolveWorktreeBaseRepoPath( |
| 1455 | projectPath: string, |
| 1456 | workspacePath: string, |
| 1457 | abortSignal?: AbortSignal |
| 1458 | ): Promise<string> { |
| 1459 | const fallbackBaseRepoPath = this.getBaseRepoPath(projectPath); |
| 1460 | |
| 1461 | try { |
| 1462 | const result = await execBuffered( |
| 1463 | this, |
| 1464 | `git -C ${this.quoteForRemote(workspacePath)} rev-parse --path-format=absolute --git-common-dir`, |
| 1465 | { |
| 1466 | cwd: "/tmp", |
| 1467 | timeout: 10, |
| 1468 | abortSignal, |
| 1469 | } |
| 1470 | ); |
| 1471 | const resolvedBaseRepoPath = result.stdout.trim(); |
| 1472 | if (result.exitCode === 0 && resolvedBaseRepoPath.length > 0) { |
| 1473 | return resolvedBaseRepoPath; |
| 1474 | } |
| 1475 | } catch { |
| 1476 | // Fall back to the canonical hashed layout when the existing workspace cannot report its |
| 1477 | // common git dir (for example, if the directory is already partially missing/corrupted). |
| 1478 | } |
| 1479 | |
| 1480 | return fallbackBaseRepoPath; |
| 1481 | } |
| 1482 | |
| 1483 | /** |
| 1484 | * Detect whether a remote workspace is a git worktree (`.git` is a file) |
no test coverage detected