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

Function editAndSync

__tests__/sync.test.ts:904–918  ·  view source on GitHub ↗

* Index `files`, rewrite one of them, sync, and return the callers of `name` * before the edit, after the sync, and from a fresh index of the edited tree * — the answer a synced index must agree with.

(
    files: Record<string, string>,
    include: string[],
    editPath: string,
    edited: string,
    name: string
  )

Source from the content-addressed store, hash-verified

902 * — the answer a synced index must agree with.
903 */
904 async function editAndSync(
905 files: Record<string, string>,
906 include: string[],
907 editPath: string,
908 edited: string,
909 name: string
910 ) {
911 const { dir, cg } = await indexProject(files, include);
912 const before = callersOf(cg, name);
913 fs.writeFileSync(path.join(dir, editPath), edited);
914 const result = await cg.sync();
915 expect(result.filesModified).toBe(1);
916 const fresh = await indexProject({ ...files, [editPath]: edited }, include);
917 return { before, synced: callersOf(cg, name), fresh: callersOf(fresh.cg, name) };
918 }
919
920 const tsOps = [
921 `export class Foo {`,

Callers 1

sync.test.tsFile · 0.85

Calls 4

indexProjectFunction · 0.70
callersOfFunction · 0.70
joinMethod · 0.45
syncMethod · 0.45

Tested by

no test coverage detected