MCPcopy Index your code
hub / github.com/antonmedv/gitmal / scanMessageBody

Function scanMessageBody

pkg/gitdiff/patch_header.go:321–355  ·  view source on GitHub ↗
(s *bufio.Scanner, indent string, separateAppendix bool)

Source from the content-addressed store, hash-verified

319}
320
321func 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
357func parseHeaderMail(mailLine string, r io.Reader, opts patchHeaderOptions) (*PatchHeader, error) {
358 msg, err := mail.ReadMessage(r)

Callers 2

parseHeaderPrettyFunction · 0.85
parseHeaderMailFunction · 0.85

Calls 3

WriteByteMethod · 0.80
WriteStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected