MCPcopy Create free account
hub / github.com/MarsWang42/Awel / getFileAtRef

Function getFileAtRef

packages/cli/src/undo.ts:77–87  ·  view source on GitHub ↗

* Gets the content of a file at a given git ref. * Returns null if the file doesn't exist at that ref.

(projectCwd: string, gitRef: string, relPath: string)

Source from the content-addressed store, hash-verified

75 * Returns null if the file doesn't exist at that ref.
76 */
77function getFileAtRef(projectCwd: string, gitRef: string, relPath: string): string | null {
78 try {
79 return execSync(`git show ${gitRef}:${relPath}`, {
80 cwd: projectCwd,
81 stdio: ['pipe', 'pipe', 'pipe'],
82 maxBuffer: 10 * 1024 * 1024, // 10MB
83 }).toString();
84 } catch {
85 return null; // File didn't exist at that ref
86 }
87}
88
89/**
90 * Discovers files that changed since the session baseline by combining

Callers 3

popAndRestoreSessionFunction · 0.85
getLatestSessionDiffsFunction · 0.85
getCurrentSessionStatsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected