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

Function parsePatchHeader

packages/opencode/src/patch/index.ts:70–101  ·  view source on GitHub ↗
(
  lines: string[],
  startIdx: number,
)

Source from the content-addressed store, hash-verified

68
69// Parser implementation
70function parsePatchHeader(
71 lines: string[],
72 startIdx: number,
73): { filePath: string; movePath?: string; nextIdx: number } | null {
74 const line = lines[startIdx]
75
76 if (line.startsWith("*** Add File:")) {
77 const filePath = line.slice("*** Add File:".length).trim()
78 return filePath ? { filePath, nextIdx: startIdx + 1 } : null
79 }
80
81 if (line.startsWith("*** Delete File:")) {
82 const filePath = line.slice("*** Delete File:".length).trim()
83 return filePath ? { filePath, nextIdx: startIdx + 1 } : null
84 }
85
86 if (line.startsWith("*** Update File:")) {
87 const filePath = line.slice("*** Update File:".length).trim()
88 let movePath: string | undefined
89 let nextIdx = startIdx + 1
90
91 // Check for move directive
92 if (nextIdx < lines.length && lines[nextIdx].startsWith("*** Move to:")) {
93 movePath = lines[nextIdx].slice("*** Move to:".length).trim()
94 nextIdx++
95 }
96
97 return filePath ? { filePath, movePath, nextIdx } : null
98 }
99
100 return null
101}
102
103function parseUpdateFileChunks(lines: string[], startIdx: number): { chunks: UpdateFileChunk[]; nextIdx: number } {
104 const chunks: UpdateFileChunk[] = []

Callers 1

parsePatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected