MCPcopy Create free account
hub / github.com/ReviewStage/stage-cli / buildFileContents

Function buildFileContents

packages/cli/src/routes/diff.ts:207–234  ·  view source on GitHub ↗
(
	run: ChapterRunRow,
	repoRoot: string,
	patch: string,
)

Source from the content-addressed store, hash-verified

205 } else {
206 const firstLine = text.slice(0, text.indexOf("\n") === -1 ? undefined : text.indexOf("\n"));
207 const halves = splitEqualGitHeader(firstLine);
208 if (halves) {
209 [oldPath, newPath] = halves;
210 } else {
211 const header = text.match(DIFF_GIT_RE);
212 oldPath = header?.[1] ?? null;
213 newPath = header?.[2] ?? null;
214 }
215 }
216 }
217
218 results.push({ oldPath, newPath, isBinary, oldIsSymlink, newIsSymlink, modeUnknown });
219 }
220
221 return results;
222}
223
224/** Adapter: decode an already-unwrapped quoted capture, tolerating absence. */
225function decodeQuotedGitPathCapture(capture: string | undefined): string | null {
226 if (capture === undefined) return null;
227 return decodeQuotedGitPath(capture);
228}
229
230async function getGitFileContent(
231 cwd: string,
232 ref: string,
233 filePath: string,
234): Promise<string | null> {
235 try {
236 const { stdout } = await execFileAsync("git", ["show", `${ref}:${filePath}`], {
237 cwd,

Callers 1

diffRoutesFunction · 0.85

Calls 3

parseFilePathsFromPatchFunction · 0.85
getContentRefsFunction · 0.85
fetchContentFunction · 0.85

Tested by

no test coverage detected