MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / branchNodeOf

Function branchNodeOf

graph-ui/src/galaxy/node-names.ts:32–48  ·  view source on GitHub ↗
(node: NodeNameParts)

Source from the content-addressed store, hash-verified

30export interface BranchNode { project?: string; name: string; state: 'detached' | 'working-tree' | 'branch' }
31
32export function branchNodeOf(node: NodeNameParts): BranchNode | undefined {
33 const label = node.label || node.kind;
34 const at = node.qualifiedName?.indexOf(BRANCH_MARK) ?? -1;
35 if (label ? label !== 'Branch' : at <= 0) return undefined;
36 const slug = at > 0 ? node.qualifiedName!.slice(at + BRANCH_MARK.length) : undefined;
37 const project = at > 0 ? node.qualifiedName!.slice(0, at) : node.project || undefined;
38 /*
39 * The engine names a detached HEAD "DETACHED" with the slug "detached".
40 * A search hit carries no name, only the qualified name, so its name is
41 * the slug ("detached"); a branch that is really called "detached" looks
42 * the same and is taken for the far more common detached HEAD. The slug
43 * keeps the case of the branch, so "Detached" stays a branch.
44 */
45 const detached = slug === undefined ? node.name === 'DETACHED' : slug === 'detached';
46 const state = detached ? 'detached' : node.name === 'working-tree' && (slug === undefined || slug === 'working-tree') ? 'working-tree' : 'branch';
47 return { ...project ? { project } : {}, name: node.name, state };
48}
49
50/** The shown name: "django-demo · detached HEAD" for a Branch node, the node's own name for every other. */
51export function nodeDisplayName(node: NodeNameParts, words: BranchNameWords = galaxyNodeNameText): string {

Callers 5

node-names.test.tsFile · 0.90
nodeDisplayNameFunction · 0.85
graphNodeTitleFunction · 0.85
graphNodeIndexNameFunction · 0.85
nodeFilePathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected