( buffer: Buffer, repository: Repository, file: FileChange, newestCommitish: string, oldestCommitish: string, lineEndingsChange?: LineEndingsChange )
| 809 | } |
| 810 | |
| 811 | async function buildDiff( |
| 812 | buffer: Buffer, |
| 813 | repository: Repository, |
| 814 | file: FileChange, |
| 815 | newestCommitish: string, |
| 816 | oldestCommitish: string, |
| 817 | lineEndingsChange?: LineEndingsChange |
| 818 | ): Promise<IDiff> { |
| 819 | if (file.status.submoduleStatus !== undefined) { |
| 820 | return buildSubmoduleDiff( |
| 821 | buffer, |
| 822 | repository, |
| 823 | file, |
| 824 | file.status.submoduleStatus |
| 825 | ) |
| 826 | } |
| 827 | |
| 828 | if (!isValidBuffer(buffer)) { |
| 829 | // the buffer's diff is too large to be renderable in the UI |
| 830 | return { kind: DiffType.Unrenderable } |
| 831 | } |
| 832 | |
| 833 | const diff = diffFromRawDiffOutput(buffer) |
| 834 | |
| 835 | if (isBufferTooLarge(buffer) || isDiffTooLarge(diff)) { |
| 836 | // we don't want to render by default |
| 837 | // but we keep it as an option by |
| 838 | // passing in text and hunks |
| 839 | const largeTextDiff: ILargeTextDiff = { |
| 840 | kind: DiffType.LargeText, |
| 841 | text: diff.contents, |
| 842 | hunks: diff.hunks, |
| 843 | lineEndingsChange, |
| 844 | maxLineNumber: diff.maxLineNumber, |
| 845 | hasHiddenBidiChars: diff.hasHiddenBidiChars, |
| 846 | } |
| 847 | |
| 848 | return largeTextDiff |
| 849 | } |
| 850 | |
| 851 | return convertDiff( |
| 852 | repository, |
| 853 | file, |
| 854 | diff, |
| 855 | newestCommitish, |
| 856 | oldestCommitish, |
| 857 | lineEndingsChange |
| 858 | ) |
| 859 | } |
| 860 | |
| 861 | /** |
| 862 | * Retrieve the binary contents of a blob from the object database |
no test coverage detected