• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fornellas / resonance / 17129370987

21 Aug 2025 02:07PM UTC coverage: 41.933% (-12.0%) from 53.969%
17129370987

Pull #314

github

web-flow
Merge ee4ffb473 into b81990ff8
Pull Request #314: Drop old interface

4 of 27 new or added lines in 7 files covered. (14.81%)

319 existing lines in 19 files now uncovered.

2308 of 5504 relevant lines covered (41.93%)

6.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/diff/diff.go
1
// Diff related utilities.
2
package diff
3

4
import (
5
        "bytes"
6
        "fmt"
7

8
        "github.com/fatih/color"
9
        "github.com/kylelemons/godebug/diff"
10
)
11

12
// Chunks represents a collection of chunks that describe the difference between two
13
// texts. Each chunk describes a series of added, deleted, and equal lines.
14
// The primary purpose of Chunks is to display text differences in a readable format,
15
// with added lines prefixed with '+' and deleted lines prefixed with '-'.
16
// ANSI colors are used unless color.NoColor is set.
17
type Chunks []diff.Chunk
18

19
// HasChanges return true when the chunks contains changes.
NEW
20
func (c Chunks) HasChanges() bool {
×
NEW
21
        for _, chunk := range c {
×
22
                if len(chunk.Added) > 0 {
×
23
                        return true
×
24
                }
×
UNCOV
25
                if len(chunk.Deleted) > 0 {
×
UNCOV
26
                        return true
×
UNCOV
27
                }
×
28
        }
UNCOV
29
        return false
×
30
}
31

NEW
32
func (c Chunks) added(i int, lines []string, buff *bytes.Buffer) {
×
UNCOV
33
        for _, line := range lines {
×
NEW
34
                if (i == 0 || i == len(c)-1) && line == "" {
×
35
                        continue
×
36
                }
UNCOV
37
                if color.NoColor {
×
UNCOV
38
                        fmt.Fprintf(buff, "+%s\n", line)
×
UNCOV
39
                } else {
×
40
                        reset := color.New(color.Reset)
×
41
                        reset.Fprintf(buff, "")
×
42
                        color.New(color.FgGreen).Fprintf(buff, "+%s", line)
×
43
                        reset.Fprintf(buff, "")
×
44
                        fmt.Fprintf(buff, "\n")
×
45
                }
×
46
        }
47
}
48

NEW
49
func (c Chunks) deleted(i int, lines []string, buff *bytes.Buffer) {
×
UNCOV
50
        for _, line := range lines {
×
NEW
51
                if (i == 0 || i == len(c)-1) && line == "" {
×
52
                        continue
×
53
                }
UNCOV
54
                if color.NoColor {
×
UNCOV
55
                        fmt.Fprintf(buff, "-%s\n", line)
×
UNCOV
56
                } else {
×
57
                        reset := color.New(color.Reset)
×
58
                        reset.Fprintf(buff, "")
×
59
                        color.New(color.FgRed).Fprintf(buff, "-%s", line)
×
60
                        reset.Fprintf(buff, "")
×
61
                        fmt.Fprintf(buff, "\n")
×
62
                }
×
63
        }
64
}
65

NEW
66
func (c Chunks) equal(i int, lines []string, buff *bytes.Buffer) {
×
UNCOV
67
        for _, line := range lines {
×
NEW
68
                if (i == 0 || i == len(c)-1) && line == "" {
×
69
                        continue
×
70
                }
UNCOV
71
                fmt.Fprintf(buff, "%s\n", line)
×
72
        }
73
}
74

NEW
75
func (c Chunks) String() string {
×
UNCOV
76
        var buff bytes.Buffer
×
NEW
77
        for i, chunk := range c {
×
NEW
78
                c.added(i, chunk.Added, &buff)
×
NEW
79
                c.deleted(i, chunk.Deleted, &buff)
×
NEW
80
                c.equal(i, chunk.Equal, &buff)
×
UNCOV
81
        }
×
UNCOV
82
        return buff.String()
×
83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc