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

Function readFileContent

packages/cli/src/routes/diff.ts:171–180  ·  view source on GitHub ↗
(repoRoot: string, filePath: string)

Source from the content-addressed store, hash-verified

169 const segment = segments[i];
170 if (segment === undefined) continue;
171 const text = i === 0 ? segment : `diff --git ${segment}`;
172 if (!text.startsWith("diff --git ")) continue;
173
174 const isBinary = BINARY_RE.test(text);
175 const hunkStart = text.search(/^@@ /m);
176 const header = hunkStart === -1 ? text : text.slice(0, hunkStart);
177 // `index ... <mode>` covers unchanged-mode diffs (both sides identical);
178 // old/new (or deleted/new file) mode lines cover transitions.
179 const sharedMode = header.match(INDEX_MODE_RE)?.[1];
180 const oldMode = header.match(OLD_MODE_RE)?.[1] ?? sharedMode;
181 const newMode = header.match(NEW_MODE_RE)?.[1] ?? sharedMode;
182 const oldIsSymlink = oldMode === SYMLINK_MODE;
183 const newIsSymlink = newMode === SYMLINK_MODE;

Callers 1

fetchContentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected