push
travis-ci
2043 of 2458 relevant lines covered (83.12%)
2731421.69 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) { |
17,577✔ |
26 |
isLast := true
|
17,577✔ |
27 |
i := len(path) - 1 |
17,577✔ |
28 |
|
17,577✔ |
29 |
var count int |
17,577✔ |
30 |
for i >= 0 { |
383,238✔ |
31 |
if os.IsPathSeparator(path[i]) {
|
391,029✔ |
32 |
count++ |
25,368✔ |
33 |
if count >= n {
|
35,672✔ |
34 |
isLast = false
|
10,304✔ |
35 |
break
|
10,304✔ |
36 |
} |
|
37 |
} |
|
38 |
i-- |
355,360✔ |
39 |
} |
|
40 |
return path[i+1:], isLast |
17,577✔ |
41 |
} |
|
42 |
|
|
43 |
func hasMeta(path string) bool { |
378✔ |
44 |
return strings.IndexAny(path, "*?[") >= 0 |
378✔ |
45 |
} |
378✔ |