* Determine text/binary status for a single file * Uses 2-tier approach: extension lists first, then blob content analysis for unknown extensions
(repoPath: string, file: FileRecord)
| 313 | * Uses 2-tier approach: extension lists first, then blob content analysis for unknown extensions |
| 314 | */ |
| 315 | async function determineTextStatusForFile(repoPath: string, file: FileRecord): Promise<FileRecord> { |
| 316 | if (file.skipReason) { |
| 317 | return file; |
| 318 | } |
| 319 | |
| 320 | // Step 1: Check against known text/binary extension lists |
| 321 | const extensionType = getExtensionType(file.path); |
| 322 | |
| 323 | if (extensionType === 'text') { |
| 324 | return { |
| 325 | ...file, |
| 326 | isText: true, |
| 327 | }; |
| 328 | } |
| 329 | |
| 330 | if (extensionType === 'binary') { |
| 331 | return { |
| 332 | ...file, |
| 333 | isText: false, |
| 334 | skipReason: 'binary', |
| 335 | }; |
| 336 | } |
| 337 | |
| 338 | // Step 2: For unknown extensions, analyze blob content |
| 339 | const checkSha = file.shaB || file.shaA; |
| 340 | if (!checkSha) { |
| 341 | return { |
| 342 | ...file, |
| 343 | isText: false, |
| 344 | skipReason: 'binary', |
| 345 | }; |
| 346 | } |
| 347 | |
| 348 | const textStatus = await isBlobText(repoPath, checkSha); |
| 349 | |
| 350 | if (textStatus) { |
| 351 | return { |
| 352 | ...file, |
| 353 | isText: true, |
| 354 | }; |
| 355 | } else { |
| 356 | return { |
| 357 | ...file, |
| 358 | isText: false, |
| 359 | skipReason: 'binary', |
| 360 | }; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | async function determineTextStatus(repoPath: string, files: FileRecord[]): Promise<FileRecord[]> { |
| 365 | return async.mapLimit(files, TEXT_DETECTION_CONCURRENCY, async (file: FileRecord) => |
no test coverage detected
searching dependent graphs…