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

Function editAndSync

__tests__/sync.test.ts:903–917  ·  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

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