(diff *Diff)
| 642 | } |
| 643 | |
| 644 | func (diffView *DiffView) generateDiffLinesForDiff(diff *Diff) (lines []*diffLineData, err error) { |
| 645 | scanner := bufio.NewScanner(&diff.stats) |
| 646 | |
| 647 | for scanner.Scan() { |
| 648 | line := scanner.Text() |
| 649 | |
| 650 | if diffStatsSummaryRegex.MatchString(line) { |
| 651 | lines = append(lines, newDiffLineData(line, dltDiffStatsSummary, CmpDiffviewDifflineNormal)) |
| 652 | continue |
| 653 | } |
| 654 | |
| 655 | filePart, changePart, err := diffView.splitDiffStatsFileLine(line) |
| 656 | if err != nil { |
| 657 | log.Warnf("Diff stats line in unexpected format: %v - %v", line, err) |
| 658 | continue |
| 659 | } |
| 660 | |
| 661 | sections := []*diffLineSection{ |
| 662 | &diffLineSection{ |
| 663 | text: filePart + " |", |
| 664 | themeComponentID: CmpDiffviewDifflineDiffStatsFile, |
| 665 | }, |
| 666 | } |
| 667 | |
| 668 | if strings.Contains(changePart, " -> ") { |
| 669 | sections = append(sections, &diffLineSection{ |
| 670 | text: changePart, |
| 671 | themeComponentID: CmpDiffviewDifflineNormal, |
| 672 | }) |
| 673 | } else { |
| 674 | for _, char := range changePart { |
| 675 | switch char { |
| 676 | case '+': |
| 677 | sections = append(sections, &diffLineSection{ |
| 678 | text: "+", |
| 679 | themeComponentID: CmpDiffviewDifflineLineAdded, |
| 680 | }) |
| 681 | case '-': |
| 682 | sections = append(sections, &diffLineSection{ |
| 683 | text: "-", |
| 684 | themeComponentID: CmpDiffviewDifflineLineRemoved, |
| 685 | }) |
| 686 | default: |
| 687 | sections = append(sections, &diffLineSection{ |
| 688 | text: fmt.Sprintf("%c", char), |
| 689 | themeComponentID: CmpDiffviewDifflineNormal, |
| 690 | }) |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | lines = append(lines, newSectionedDiffLineData(sections, dltDiffStatsFile)) |
| 696 | } |
| 697 | |
| 698 | if len(lines) > 0 { |
| 699 | lines = append(lines, newEmptyDiffLineData()) |
| 700 | } |
| 701 |
no test coverage detected