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

Function fileFromGitHeader

packages/opencode/src/project/vcs.ts:64–76  ·  view source on GitHub ↗
(header: string)

Source from the content-addressed store, hash-verified

62}
63
64const fileFromGitHeader = (header: string) => {
65 if (header.startsWith('"')) {
66 const first = parseQuotedPath(header)
67 const second = first ? header.slice(first.end).trimStart() : undefined
68 if (!second) return
69 if (!second.startsWith('"')) return fileFromDiffPath(second)
70 return fileFromDiffPath(parseQuotedPath(second)?.value)
71 }
72
73 const separator = header.indexOf(" b/")
74 if (separator === -1) return
75 return fileFromDiffPath(header.slice(separator + 1))
76}
77
78const fileFromPatchChunk = (chunk: string) => {
79 const next = /^\+\+\+ (.+)$/m.exec(chunk)?.[1]

Callers 1

fileFromPatchChunkFunction · 0.85

Calls 2

parseQuotedPathFunction · 0.85
fileFromDiffPathFunction · 0.85

Tested by

no test coverage detected