MCPcopy Create free account
hub / github.com/anomalyco/opencode / fileFromPatchChunk

Function fileFromPatchChunk

packages/opencode/src/project/vcs.ts:78–86  ·  view source on GitHub ↗
(chunk: string)

Source from the content-addressed store, hash-verified

76}
77
78const fileFromPatchChunk = (chunk: string) => {
79 const next = /^\+\+\+ (.+)$/m.exec(chunk)?.[1]
80 const before = /^--- (.+)$/m.exec(chunk)?.[1]
81 const file = fileFromDiffPath(next) ?? fileFromDiffPath(before)
82 if (file) return file
83
84 const header = /^diff --git (.+)$/m.exec(chunk)?.[1]
85 return fileFromGitHeader(header ?? "")
86}
87
88const splitGitPatch = (patch: Git.Patch) => {
89 const starts = [...patch.text.matchAll(/(?:^|\n)diff --git /g)].map((match) =>

Callers 1

vcs.tsFile · 0.85

Calls 2

fileFromDiffPathFunction · 0.85
fileFromGitHeaderFunction · 0.85

Tested by

no test coverage detected