MCPcopy Create free account
hub / github.com/agenticsorg/edge-agents / createCheckpoint

Function createCheckpoint

scripts/sparc2/src/git/gitIntegration.ts:325–367  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

323 * @returns The commit hash of the checkpoint
324 */
325export async function createCheckpoint(name: string): Promise<string> {
326 // Add a timestamp to make the tag name unique
327 const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
328 const uniqueName = `${name}-${timestamp}`;
329
330 // Create a tag for the checkpoint
331 const tagCmd = new Deno.Command("git", {
332 args: ["tag", uniqueName],
333 stdout: "piped",
334 stderr: "piped",
335 });
336
337 const tagOutput = await tagCmd.output();
338 if (!tagOutput.success) {
339 const errorOutput = new TextDecoder().decode(tagOutput.stderr);
340 await logMessage("error", `Creating checkpoint tag failed: ${errorOutput}`, {
341 name: uniqueName,
342 });
343 throw new Error(`Creating checkpoint tag failed: ${errorOutput}`);
344 }
345
346 // Get the commit hash for the tag
347 const revParseCmd = new Deno.Command("git", {
348 args: ["rev-parse", uniqueName],
349 stdout: "piped",
350 stderr: "piped",
351 });
352
353 const revParseOutput = await revParseCmd.output();
354 if (!revParseOutput.success) {
355 const errorOutput = new TextDecoder().decode(revParseOutput.stderr);
356 await logMessage("error", `Getting checkpoint commit hash failed: ${errorOutput}`, {
357 name: uniqueName,
358 });
359 throw new Error(`Getting checkpoint commit hash failed: ${errorOutput}`);
360 }
361
362 const commitHash = new TextDecoder().decode(revParseOutput.stdout).trim();
363
364 await logMessage("info", `Created checkpoint ${uniqueName} at commit ${commitHash}`);
365
366 return commitHash;
367}
368
369/**
370 * Get the current branch name

Callers 4

startMCPServerFunction · 0.90
startMCPServerStdioFunction · 0.90
createCheckpointMethod · 0.90

Calls 1

logMessageFunction · 0.90

Tested by

no test coverage detected