travis-ci
27 of 27 new or added lines in 3 files covered. (100.0%)
1601 of 2133 relevant lines covered (75.06%)
8.5 hits per line
1 |
package chglog
|
|
2 |
|
|
3 |
import (
|
|
4 |
"strings"
|
|
5 |
) |
|
6 |
|
|
|
func commitFilter(commits []*Commit, filters map[string][]string, insensitive bool) []*Commit { |
20✔ |
8 |
res := []*Commit{} |
20✔ |
9 |
|
20✔ |
10 |
for _, commit := range commits { |
73✔ |
11 |
include := false
|
53✔ |
12 |
|
53✔ |
13 |
if len(filters) == 0 { |
65✔ |
14 |
include = true
|
12✔ |
15 |
} |
12✔ |
16 |
|
|
17 |
for key, values := range filters { |
99✔ |
18 |
prop, ok := dotGet(commit, key) |
46✔ |
19 |
if !ok {
|
46✔ |
20 |
include = false
|
× |
21 |
break
|
× |
22 |
} |
|
23 |
|
|
24 |
str, ok := prop.(string)
|
46✔ |
25 |
if !ok {
|
46✔ |
26 |
include = false
|
× |
27 |
break
|
× |
28 |
} |
|
29 |
|
|
|
if insensitive {
|
46✔ |
|
str = strings.ToLower(str) |
× |
|
} |
× |
33 |
|
|
34 |
exist := false
|
46✔ |
35 |
|
46✔ |
36 |
for _, val := range values { |
110✔ |
|
if insensitive {
|
64✔ |
|
val = strings.ToLower(val) |
× |
|
} |
× |
40 |
|
|
41 |
if str == val {
|
93✔ |
42 |
exist = true
|
29✔ |
43 |
} |
29✔ |
44 |
} |
|
45 |
|
|
46 |
if !exist {
|
63✔ |
47 |
include = false
|
17✔ |
48 |
break
|
17✔ |
49 |
} |
|
50 |
|
|
51 |
include = true
|
29✔ |
52 |
} |
|
53 |
|
|
54 |
if include {
|
89✔ |
55 |
res = append(res, commit)
|
36✔ |
56 |
} |
36✔ |
57 |
} |
|
58 |
|
|
59 |
return res
|
20✔ |
60 |
} |