(s *bufio.Scanner, indent string, separateAppendix bool)
| 319 | } |
| 320 | |
| 321 | func scanMessageBody(s *bufio.Scanner, indent string, separateAppendix bool) (string, string) { |
| 322 | // Body and appendix |
| 323 | var body, appendix strings.Builder |
| 324 | c := &body |
| 325 | var empty int |
| 326 | for i := 0; s.Scan(); i++ { |
| 327 | line := s.Text() |
| 328 | |
| 329 | line = strings.TrimRightFunc(line, unicode.IsSpace) |
| 330 | line = strings.TrimPrefix(line, indent) |
| 331 | |
| 332 | if line == "" { |
| 333 | empty++ |
| 334 | continue |
| 335 | } |
| 336 | |
| 337 | // If requested, parse out "appendix" information (often added |
| 338 | // by `git format-patch` and removed by `git am`). |
| 339 | if separateAppendix && c == &body && line == "---" { |
| 340 | c = &appendix |
| 341 | continue |
| 342 | } |
| 343 | |
| 344 | if c.Len() > 0 { |
| 345 | c.WriteByte('\n') |
| 346 | if empty > 0 { |
| 347 | c.WriteByte('\n') |
| 348 | } |
| 349 | } |
| 350 | empty = 0 |
| 351 | |
| 352 | c.WriteString(line) |
| 353 | } |
| 354 | return body.String(), appendix.String() |
| 355 | } |
| 356 | |
| 357 | func parseHeaderMail(mailLine string, r io.Reader, opts patchHeaderOptions) (*PatchHeader, error) { |
| 358 | msg, err := mail.ReadMessage(r) |
no test coverage detected