(repoPath: string, sha: string)
| 272 | } |
| 273 | |
| 274 | async 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 |
no outgoing calls
no test coverage detected
searching dependent graphs…