| 155 | } |
| 156 | |
| 157 | function parseAddFileContent(lines: string[], startIdx: number): { content: string; nextIdx: number } { |
| 158 | let content = "" |
| 159 | let i = startIdx |
| 160 | |
| 161 | while (i < lines.length && !lines[i].startsWith("***")) { |
| 162 | if (lines[i].startsWith("+")) { |
| 163 | content += lines[i].substring(1) + "\n" |
| 164 | } |
| 165 | i++ |
| 166 | } |
| 167 | |
| 168 | // Remove trailing newline |
| 169 | if (content.endsWith("\n")) { |
| 170 | content = content.slice(0, -1) |
| 171 | } |
| 172 | |
| 173 | return { content, nextIdx: i } |
| 174 | } |
| 175 | |
| 176 | function stripHeredoc(input: string): string { |
| 177 | // Match heredoc patterns like: cat <<'EOF'\n...\nEOF or <<EOF\n...\nEOF |