MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / restorePoint

Function restorePoint

src/git/shadow.ts:73–95  ·  view source on GitHub ↗
(rootDir: string, pointId: string)

Source from the content-addressed store, hash-verified

71}
72
73export async function restorePoint(rootDir: string, pointId: string): Promise<string[]> {
74 const normalizedRoot = resolve(rootDir);
75 const manifest = await loadManifest(normalizedRoot);
76 const point = manifest.find((p) => p.id === pointId);
77 if (!point) throw new Error(`Restore point ${pointId} not found`);
78
79 const backupDir = join(normalizedRoot, DATA_DIR, "backups", pointId);
80 const restoredFiles: string[] = [];
81
82 for (const file of point.files) {
83 const targetPath = assertWithinRoot(normalizedRoot, file);
84 const backupPath = join(backupDir, file.replace(/[\\/]/g, "__"));
85 try {
86 const content = await readFile(backupPath, "utf-8");
87 await mkdir(dirname(targetPath), { recursive: true });
88 await writeFile(targetPath, content);
89 restoredFiles.push(file);
90 } catch {
91 }
92 }
93
94 return restoredFiles;
95}
96
97export async function listRestorePoints(rootDir: string): Promise<RestorePoint[]> {
98 return loadManifest(rootDir);

Callers 4

shadow.test.mjsFile · 0.85
shadow.demo.mjsFile · 0.85
index.tsFile · 0.85

Calls 2

loadManifestFunction · 0.85
assertWithinRootFunction · 0.85

Tested by

no test coverage detected