MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / reindexFromScratch

Function reindexFromScratch

__tests__/sync.test.ts:24–31  ·  view source on GitHub ↗

* Index `cg`'s project again from an empty database, as `codegraph index` * does, and return the new handle: the graph a synced index has to match. * indexAll over the synced index is no stand-in — it skips every file whose * content is unchanged, so the edges the sync wrote survive it untouched.

(cg: CodeGraph)

Source from the content-addressed store, hash-verified

22 * content is unchanged, so the edges the sync wrote survive it untouched.
23 */
24async function reindexFromScratch(cg: CodeGraph): Promise<CodeGraph> {
25 const root = cg.getProjectRoot();
26 // recreate unlinks the database file; a held handle makes that EBUSY on Windows.
27 cg.close();
28 const rebuilt = await CodeGraph.recreate(root);
29 await rebuilt.indexAll();
30 return rebuilt;
31}
32
33/**
34 * For a test that indexes twice in its body: on a busy host the default 5s

Callers 1

sync.test.tsFile · 0.70

Calls 4

recreateMethod · 0.80
getProjectRootMethod · 0.65
closeMethod · 0.65
indexAllMethod · 0.45

Tested by

no test coverage detected