MCPcopy Index your code
hub / github.com/anomalyco/opencode / fileDiffFromPatch

Function fileDiffFromPatch

packages/session-ui/src/components/session-diff.ts:54–71  ·  view source on GitHub ↗
(file: string, patch: string)

Source from the content-addressed store, hash-verified

52}
53
54function 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
73function completePatchContents(patch: string) {
74 try {

Callers 1

resolveFileDiffFunction · 0.85

Calls 8

completePatchContentsFunction · 0.85
patchInputFunction · 0.85
fileDiffFromContentFunction · 0.85
emptyFileDiffFunction · 0.85
getMethod · 0.65
deleteMethod · 0.45
setMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected