MCPcopy
hub / github.com/coder/mux / resolveWorktreeBaseRepoPath

Method resolveWorktreeBaseRepoPath

src/node/runtime/SSHRuntime.ts:1454–1481  ·  view source on GitHub ↗
(
    projectPath: string,
    workspacePath: string,
    abortSignal?: AbortSignal
  )

Source from the content-addressed store, hash-verified

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)

Callers 2

renameWorkspaceMethod · 0.95
deleteWorkspaceMethod · 0.95

Calls 3

getBaseRepoPathMethod · 0.95
quoteForRemoteMethod · 0.95
execBufferedFunction · 0.90

Tested by

no test coverage detected