| 484 | } |
| 485 | |
| 486 | func printDiffRecords(suppressedKinds []string, kind string, context int, diffs []difflib.DiffRecord, to io.Writer) { |
| 487 | for _, ckind := range suppressedKinds { |
| 488 | if ckind == kind { |
| 489 | str := fmt.Sprintf("+ Changes suppressed on sensitive content of type %s\n", kind) |
| 490 | _, _ = fmt.Fprint(to, ansi.Color(str, "yellow")) |
| 491 | return |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | if context >= 0 { |
| 496 | distances := calculateDistances(diffs) |
| 497 | omitting := false |
| 498 | for i, diff := range diffs { |
| 499 | if distances[i] > context { |
| 500 | if !omitting { |
| 501 | _, _ = fmt.Fprintln(to, "...") |
| 502 | omitting = true |
| 503 | } |
| 504 | } else { |
| 505 | omitting = false |
| 506 | printDiffRecord(diff, to) |
| 507 | } |
| 508 | } |
| 509 | } else { |
| 510 | for _, diff := range diffs { |
| 511 | printDiffRecord(diff, to) |
| 512 | } |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | func printDiffRecord(diff difflib.DiffRecord, to io.Writer) { |
| 517 | text := diff.Payload |