( repository: Repository, file: FileChange, newestCommitish: string, oldestCommitish: string )
| 575 | } |
| 576 | |
| 577 | async function getImageDiff( |
| 578 | repository: Repository, |
| 579 | file: FileChange, |
| 580 | newestCommitish: string, |
| 581 | oldestCommitish: string |
| 582 | ): Promise<IImageDiff> { |
| 583 | let current: Image | undefined = undefined |
| 584 | let previous: Image | undefined = undefined |
| 585 | |
| 586 | // Are we looking at a file in the working directory or a file in a commit? |
| 587 | if (file instanceof WorkingDirectoryFileChange) { |
| 588 | // No idea what to do about this, a conflicted binary (presumably) file. |
| 589 | // Ideally we'd show all three versions and let the user pick but that's |
| 590 | // a bit out of scope for now. |
| 591 | if (file.status.kind === AppFileStatusKind.Conflicted) { |
| 592 | return { kind: DiffType.Image } |
| 593 | } |
| 594 | |
| 595 | // Does it even exist in the working directory? |
| 596 | if (file.status.kind !== AppFileStatusKind.Deleted) { |
| 597 | current = await getWorkingDirectoryImage(repository, file) |
| 598 | } |
| 599 | |
| 600 | if ( |
| 601 | file.status.kind !== AppFileStatusKind.New && |
| 602 | file.status.kind !== AppFileStatusKind.Untracked |
| 603 | ) { |
| 604 | // If we have file.oldPath that means it's a rename so we'll |
| 605 | // look for that file. |
| 606 | previous = await getBlobImage( |
| 607 | repository, |
| 608 | getOldPathOrDefault(file), |
| 609 | 'HEAD' |
| 610 | ) |
| 611 | } |
| 612 | } else { |
| 613 | // File status can't be conflicted for a file in a commit |
| 614 | if (file.status.kind !== AppFileStatusKind.Deleted) { |
| 615 | current = await getBlobImage(repository, file.path, newestCommitish) |
| 616 | } |
| 617 | |
| 618 | // File status can't be conflicted for a file in a commit |
| 619 | if ( |
| 620 | file.status.kind !== AppFileStatusKind.New && |
| 621 | file.status.kind !== AppFileStatusKind.Untracked && |
| 622 | file.status.kind !== AppFileStatusKind.Deleted |
| 623 | ) { |
| 624 | // TODO: commitish^ won't work for the first commit |
| 625 | // |
| 626 | // If we have file.oldPath that means it's a rename so we'll |
| 627 | // look for that file. |
| 628 | previous = await getBlobImage( |
| 629 | repository, |
| 630 | getOldPathOrDefault(file), |
| 631 | `${oldestCommitish}^` |
| 632 | ) |
| 633 | } |
| 634 |
no test coverage detected