MCPcopy Create free account
hub / github.com/promptfoo/promptfoo / isBlobText

Function isBlobText

src/codeScan/git/diffProcessor.ts:274–291  ·  view source on GitHub ↗
(repoPath: string, sha: string)

Source from the content-addressed store, hash-verified

272}
273
274async function isBlobText(repoPath: string, sha: string): Promise<boolean> {
275 try {
276 const result = await execa('git', ['cat-file', 'blob', sha], {
277 cwd: repoPath,
278 encoding: 'buffer',
279 maxBuffer: 4096,
280 });
281
282 // Convert Uint8Array to Buffer and check if text
283 const buffer = Buffer.from(result.stdout);
284 const textCheck = isText(null, buffer);
285
286 // isText can return boolean | null, treat null as false
287 return textCheck === true;
288 } catch {
289 return false;
290 }
291}
292
293/**
294 * Check file extension against known text and binary extension lists

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…