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

Method getWorkspaceBranchMapPath

src/node/worktree/WorktreeManager.ts:700–723  ·  view source on GitHub ↗
(projectPath: string)

Source from the content-addressed store, hash-verified

698 }
699
700 private async getWorkspaceBranchMapPath(projectPath: string): Promise<string> {
701 const gitPath = path.join(projectPath, ".git");
702
703 try {
704 const gitPathStat = await fsPromises.stat(gitPath);
705 if (gitPathStat.isDirectory()) {
706 return path.join(gitPath, "mux-workspace-branches.json");
707 }
708
709 const gitDirRef = await fsPromises.readFile(gitPath, "utf8");
710 const gitDirPrefix = "gitdir:";
711 const gitDirLine = gitDirRef.trim();
712 if (gitDirLine.startsWith(gitDirPrefix)) {
713 return path.join(
714 path.resolve(projectPath, gitDirLine.slice(gitDirPrefix.length).trim()),
715 "mux-workspace-branches.json"
716 );
717 }
718 } catch {
719 // Fall through to the default .git path when git metadata is unavailable.
720 }
721
722 return path.join(gitPath, "mux-workspace-branches.json");
723 }
724
725 private async deleteWorkspaceBranchIfSafe(args: {
726 projectPath: string;

Callers 2

Calls 3

resolveMethod · 0.80
statMethod · 0.65
readFileMethod · 0.65

Tested by

no test coverage detected