MCPcopy
hub / github.com/opentrace/opentrace / ensureDirChain

Function ensureDirChain

ui/src/components/pipeline/stages/loading.ts:55–85  ·  view source on GitHub ↗
(
  repoId: string,
  dirPath: string,
  dirNodes: Map<string, GraphNode>,
  rels: GraphRelationship[],
)

Source from the content-addressed store, hash-verified

53}
54
55export function ensureDirChain(
56 repoId: string,
57 dirPath: string,
58 dirNodes: Map<string, GraphNode>,
59 rels: GraphRelationship[],
60): void {
61 if (!dirPath || dirNodes.has(dirPath)) return;
62
63 const parent = parentDir(dirPath);
64 ensureDirChain(repoId, parent, dirNodes, rels);
65
66 const dirId = `${repoId}/${dirPath}`;
67 const name = dirPath.includes('/')
68 ? dirPath.slice(dirPath.lastIndexOf('/') + 1)
69 : dirPath;
70
71 dirNodes.set(dirPath, {
72 id: dirId,
73 type: 'Directory',
74 name,
75 properties: { path: dirPath },
76 });
77
78 const targetId = parent ? `${repoId}/${parent}` : repoId;
79 rels.push({
80 id: `${targetId}->DEFINES->${dirId}`,
81 type: 'DEFINES',
82 source_id: targetId,
83 target_id: dirId,
84 });
85}

Callers 1

executeFunction · 0.90

Calls 2

pushMethod · 0.80
parentDirFunction · 0.70

Tested by

no test coverage detected