(file: string, patch: string)
| 52 | } |
| 53 | |
| 54 | function fileDiffFromPatch(file: string, patch: string) { |
| 55 | const key = `${file}\0${patch}` |
| 56 | const hit = patchFileDiffCache.get(key) |
| 57 | if (hit) { |
| 58 | patchFileDiffCache.delete(key) |
| 59 | patchFileDiffCache.set(key, hit) |
| 60 | return hit |
| 61 | } |
| 62 | |
| 63 | const contents = completePatchContents(patch) |
| 64 | const input = contents ? undefined : patchInput(file, patch) |
| 65 | const value = contents |
| 66 | ? fileDiffFromContent(file, contents.before, contents.after) |
| 67 | : ((input ? parsePatchFiles(input)[0]?.files[0] : undefined) ?? emptyFileDiff(file)) |
| 68 | patchFileDiffCache.set(key, value) |
| 69 | while (patchFileDiffCache.size > diffCacheLimit) patchFileDiffCache.delete(patchFileDiffCache.keys().next().value!) |
| 70 | return value |
| 71 | } |
| 72 | |
| 73 | function completePatchContents(patch: string) { |
| 74 | try { |
no test coverage detected