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

Method readWorkspaceBranchMap

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

Source from the content-addressed store, hash-verified

662 }
663
664 private async readWorkspaceBranchMap(projectPath: string): Promise<Record<string, string>> {
665 try {
666 const contents = await fsPromises.readFile(
667 await this.getWorkspaceBranchMapPath(projectPath),
668 "utf8"
669 );
670 const parsed: unknown = JSON.parse(contents);
671 if (typeof parsed !== "object" || parsed === null) {
672 return {};
673 }
674 return Object.fromEntries(
675 Object.entries(parsed).filter(([workspaceName, branchName]) => {
676 return (
677 workspaceName.trim().length > 0 &&
678 typeof branchName === "string" &&
679 branchName.trim().length > 0
680 );
681 })
682 );
683 } catch {
684 return {};
685 }
686 }
687
688 private async writeWorkspaceBranchMap(
689 projectPath: string,

Calls 3

readFileMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected