push
travis-ci
1906 of 2161 relevant lines covered (88.2%)
3104808.39 hits per line
1 |
package gitignore
|
|
2 |
|
|
3 |
import (
|
|
4 |
"os"
|
|
5 |
"strings"
|
|
6 |
) |
|
7 |
|
|
8 |
func cutN(path string, n int) (string, bool) { |
14✔ |
9 |
isLast := true
|
14✔ |
10 |
|
14✔ |
11 |
var i, count int |
14✔ |
12 |
for i < len(path)-1 { |
140✔ |
13 |
if os.IsPathSeparator(path[i]) {
|
126✔ |
14 |
count++ |
× |
15 |
if count >= n {
|
× |
16 |
isLast = false
|
× |
17 |
break
|
× |
18 |
} |
|
19 |
} |
|
20 |
i++ |
126✔ |
21 |
} |
|
22 |
return path[:i+1], isLast |
14✔ |
23 |
} |
|
24 |
|
|
25 |
func cutLastN(path string, n int) (string, bool) { |
16,191✔ |
26 |
isLast := true
|
16,191✔ |
27 |
i := len(path) - 1 |
16,191✔ |
28 |
|
16,191✔ |
29 |
var count int |
16,191✔ |
30 |
for i >= 0 { |
339,897✔ |
31 |
if os.IsPathSeparator(path[i]) {
|
346,945✔ |
32 |
count++ |
23,239✔ |
33 |
if count >= n {
|
32,675✔ |
34 |
isLast = false
|
9,436✔ |
35 |
break
|
9,436✔ |
36 |
} |
|
37 |
} |
|
38 |
i-- |
314,279✔ |
39 |
} |
|
40 |
return path[i+1:], isLast |
16,190✔ |
41 |
} |
|
42 |
|
|
43 |
func hasMeta(path string) bool { |
364✔ |
44 |
return strings.IndexAny(path, "*?[") >= 0 |
364✔ |
45 |
} |
364✔ |