File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ impl IgnoreCache {
39
39
40
40
match file. read_to_string ( & mut contents) {
41
41
Ok ( _) => {
42
- let ( patterns, mut _errors ) = IgnorePatterns :: parse_from_iter ( contents. lines ( ) ) ;
42
+ let patterns = file_lines_to_patterns ( contents. lines ( ) ) ;
43
43
entries. push ( ( p. into ( ) , patterns) ) ;
44
44
}
45
45
Err ( e) => debug ! ( "Failed to read a .gitignore: {:?}" , e)
@@ -68,10 +68,32 @@ impl IgnoreCache {
68
68
}
69
69
70
70
71
+ fn file_lines_to_patterns < ' a , I > ( iter : I ) -> IgnorePatterns
72
+ where I : Iterator < Item =& ' a str > {
73
+ // Errors are currently being ignored... not a good look
74
+ IgnorePatterns :: parse_from_iter ( iter) . 0
75
+ }
76
+
77
+
71
78
#[ cfg( test) ]
72
79
mod test {
73
80
use super :: * ;
74
81
82
+ #[ test]
83
+ fn parse_nothing ( ) {
84
+ use std:: iter:: empty;
85
+ let ( patterns, _) = IgnorePatterns :: parse_from_iter ( empty ( ) ) ;
86
+ assert_eq ! ( patterns, file_lines_to_patterns( empty( ) ) ) ;
87
+ }
88
+
89
+ #[ test]
90
+ fn parse_some_globs ( ) {
91
+ let stuff = vec ! [ "*.mp3" , "README.md" ] ;
92
+ let ( patterns, _) = IgnorePatterns :: parse_from_iter ( stuff. iter ( ) . cloned ( ) ) ;
93
+ assert_eq ! ( patterns, file_lines_to_patterns( stuff. into_iter( ) ) ) ;
94
+ }
95
+
96
+
75
97
#[ test]
76
98
fn empty ( ) {
77
99
let ignores = IgnoreCache :: default ( ) ;
You can’t perform that action at this time.
0 commit comments