(patch: string, allowTruncation: boolean = true)
| 1869 | } |
| 1870 | |
| 1871 | function finalizeFilePatchResponse(patch: string, allowTruncation: boolean = true): GetFilePatchResponse { |
| 1872 | if (!patch) { |
| 1873 | return createEmptyFilePatchResponse() |
| 1874 | } |
| 1875 | |
| 1876 | const truncated = allowTruncation && patch.length > MAX_PATCH_SIZE |
| 1877 | const patchStats = parsePatchStats(patch) |
| 1878 | const changedLines = patchStats.insertions + patchStats.deletions |
| 1879 | const hunkCount = countHunks(patch) |
| 1880 | |
| 1881 | return { |
| 1882 | patch: truncated ? patch.slice(0, MAX_PATCH_SIZE) : patch, |
| 1883 | truncated, |
| 1884 | heavy: truncated || patch.length > 256 * 1024 || changedLines > 4_000 || hunkCount > 50, |
| 1885 | stats: { |
| 1886 | insertions: patchStats.insertions, |
| 1887 | deletions: patchStats.deletions, |
| 1888 | changedLines, |
| 1889 | hunkCount, |
| 1890 | }, |
| 1891 | } |
| 1892 | } |
| 1893 | |
| 1894 | async function getUntrackedFilePatch( |
| 1895 | workDir: string, |
no test coverage detected