()
| 448 | } |
| 449 | |
| 450 | async filesStatus() { |
| 451 | const baseOpts = this._baseOpts; |
| 452 | |
| 453 | // Adopted from statusMatrix of isomorphic-git https://github.com/isomorphic-git/isomorphic-git/blob/main/src/api/statusMatrix.js#L157 |
| 454 | const status: { |
| 455 | filepath: string; |
| 456 | head: { name: string; status: HeadStatus }; |
| 457 | workdir: { name: string; status: WorkdirStatus }; |
| 458 | stage: { name: string; status: StageStatus }; |
| 459 | }[] = await git.walk({ |
| 460 | ...baseOpts, |
| 461 | trees: [ |
| 462 | // What the latest commit on the current branch looks like |
| 463 | git.TREE({ ref: 'HEAD' }), |
| 464 | // What the working directory looks like |
| 465 | git.WORKDIR(), |
| 466 | // What the index (staging area) looks like |
| 467 | git.STAGE(), |
| 468 | ], |
| 469 | map: async function map(filepath, [head, workdir, stage]) { |
| 470 | if (baseOpts.legacyDiff) { |
| 471 | const isInsomniaFile = |
| 472 | filepath.startsWith(GIT_INSOMNIA_DIR_NAME) || filepath.startsWith('insomnia.') || filepath === '.'; |
| 473 | if (!isInsomniaFile) { |
| 474 | return null; |
| 475 | } |
| 476 | } else { |
| 477 | // If the path is a file with an extension different than yaml we don't want to check it |
| 478 | if (path.extname(filepath) && path.extname(filepath) !== '.yaml') { |
| 479 | return null; |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | if ( |
| 484 | await git.isIgnored({ |
| 485 | ...baseOpts, |
| 486 | filepath, |
| 487 | }) |
| 488 | ) { |
| 489 | return null; |
| 490 | } |
| 491 | const [headType, workdirType, stageType] = await Promise.all([ |
| 492 | head && head.type(), |
| 493 | workdir && workdir.type(), |
| 494 | stage && stage.type(), |
| 495 | ]); |
| 496 | |
| 497 | const isBlob = [headType, workdirType, stageType].includes('blob'); |
| 498 | |
| 499 | // For now, bail on directories unless the file is also a blob in another tree |
| 500 | if ((headType === 'tree' || headType === 'special') && !isBlob) { |
| 501 | return; |
| 502 | } |
| 503 | if (headType === 'commit') { |
| 504 | return null; |
| 505 | } |
| 506 | |
| 507 | if ((workdirType === 'tree' || workdirType === 'special') && !isBlob) { |
no test coverage detected