(input: string)
| 174 | } |
| 175 | |
| 176 | function stripHeredoc(input: string): string { |
| 177 | // Match heredoc patterns like: cat <<'EOF'\n...\nEOF or <<EOF\n...\nEOF |
| 178 | const heredocMatch = input.match(/^(?:cat\s+)?<<['"]?(\w+)['"]?\s*\n([\s\S]*?)\n\1\s*$/) |
| 179 | if (heredocMatch) { |
| 180 | return heredocMatch[2] |
| 181 | } |
| 182 | return input |
| 183 | } |
| 184 | |
| 185 | export function parsePatch(patchText: string): { hunks: Hunk[] } { |
| 186 | const cleaned = stripHeredoc(patchText.trim()) |