11use crate :: paths:: DotPaths ;
2+ use crate :: settings:: dotfile_dir;
23use crate :: settings:: dots:: { Dot , DotOverride } ;
34use crate :: templating:: Variables ;
45use anyhow:: Result ;
@@ -7,19 +8,20 @@ use std::fs;
78use std:: fs:: File ;
89use std:: io:: Write ;
910use std:: path:: { Path , PathBuf } ;
10- use crate :: settings:: dotfile_dir;
1111
1212impl Dot {
13- pub ( crate ) fn install (
14- & self ,
15- vars : & Variables ,
16- auto_ignored : Vec < PathBuf > ,
17- ) -> Result < ( ) > {
13+ pub ( crate ) fn install ( & self , vars : & Variables , auto_ignored : Vec < PathBuf > ) -> Result < ( ) > {
1814 let source = & self . source ( ) ?;
1915 let copy_path = & self . build_copy_path ( ) ;
2016 let source_str = source. to_str ( ) . unwrap_or_default ( ) ;
21- let mut ignored_paths = self . get_ignored_paths ( source_str) ?;
22- ignored_paths. extend_from_slice ( & auto_ignored) ;
17+
18+ let ignored_paths = if self . ignore . is_empty ( ) {
19+ auto_ignored
20+ } else {
21+ let mut ignored_paths = self . get_ignored_paths ( source_str) ?;
22+ ignored_paths. extend_from_slice ( & auto_ignored) ;
23+ ignored_paths
24+ } ;
2325
2426 // Add local vars to the global ones
2527 let mut vars = vars. clone ( ) ;
@@ -101,10 +103,7 @@ impl Dot {
101103}
102104
103105impl DotOverride {
104- pub ( crate ) fn resolve_var_path (
105- & self ,
106- origin : Option < & PathBuf > ,
107- ) -> Option < PathBuf > {
106+ pub ( crate ) fn resolve_var_path ( & self , origin : Option < & PathBuf > ) -> Option < PathBuf > {
108107 let source = match ( self . get_source ( ) , origin) {
109108 ( Some ( source) , _) => source,
110109 ( None , Some ( origin) ) => origin,
@@ -116,9 +115,7 @@ impl DotOverride {
116115 }
117116}
118117
119- impl Dot {
120-
121- }
118+ impl Dot { }
122119
123120pub ( crate ) trait DotVar {
124121 fn vars ( & self ) -> Option < PathBuf > ;
@@ -131,11 +128,7 @@ pub(crate) trait DotVar {
131128 self . vars ( ) == Some ( Dot :: default_vars ( ) )
132129 }
133130
134- fn resolve_from_source (
135- & self ,
136- source : & Path ,
137- path : & Path ,
138- ) -> Option < PathBuf > {
131+ fn resolve_from_source ( & self , source : & Path , path : & Path ) -> Option < PathBuf > {
139132 let relative_to_dot = dotfile_dir ( ) . join ( source) . join ( path) ;
140133 let relative_to_dotfile_dir = dotfile_dir ( ) . join ( path) ;
141134 // FIXME : we should not try to look for path like this
@@ -156,11 +149,7 @@ pub(crate) trait DotVar {
156149 }
157150 }
158151
159- fn vars_path_not_found (
160- & self ,
161- source : & Path ,
162- path : & Path ,
163- ) -> Option < PathBuf > {
152+ fn vars_path_not_found ( & self , source : & Path , path : & Path ) -> Option < PathBuf > {
164153 if !self . is_default_var_path ( ) {
165154 eprintln ! (
166155 "{} {:?} {} {:?} {} {:?}" ,
@@ -277,7 +266,6 @@ mod tests {
277266 vars : Dot :: default_vars ( ) ,
278267 } ;
279268
280-
281269 // Act
282270 dot. symlink ( ) ?;
283271
@@ -307,19 +295,17 @@ mod tests {
307295 & Variables :: default ( ) ,
308296 ) ?;
309297
310- run_cmd ! ( tree -a) ?;
311-
312-
298+ run_cmd ! ( tree - a) ?;
313299
314300 // Assert
315- let file_one = PathBuf :: from ( "dotfiles_with_multiple_nested_dir/.dots/dir/subdir_one/subfile" ) ;
316- let file_two = PathBuf :: from ( "dotfiles_with_multiple_nested_dir/.dots/dir/subdir_two/subfile" ) ;
301+ let file_one =
302+ PathBuf :: from ( "dotfiles_with_multiple_nested_dir/.dots/dir/subdir_one/subfile" ) ;
303+ let file_two =
304+ PathBuf :: from ( "dotfiles_with_multiple_nested_dir/.dots/dir/subdir_two/subfile" ) ;
317305 assert_that ! ( file_one) . exists ( ) ;
318306 assert_that ! ( file_two) . exists ( ) ;
319- assert_that ! ( fs:: read_to_string( file_one) ?)
320- . is_equal_to ( & "Hello From subdir 1" . to_string ( ) ) ;
321- assert_that ! ( fs:: read_to_string( file_two) ?)
322- . is_equal_to ( & "Hello From subdir 2" . to_string ( ) ) ;
307+ assert_that ! ( fs:: read_to_string( file_one) ?) . is_equal_to ( & "Hello From subdir 1" . to_string ( ) ) ;
308+ assert_that ! ( fs:: read_to_string( file_two) ?) . is_equal_to ( & "Hello From subdir 2" . to_string ( ) ) ;
323309 Ok ( ( ) )
324310 }
325311
@@ -342,7 +328,7 @@ mod tests {
342328 & Variables :: default ( ) ,
343329 ) ?;
344330
345- run_cmd ! ( tree -a) ?;
331+ run_cmd ! ( tree - a) ?;
346332
347333 assert_that ! ( PathBuf :: from( "dotfiles_non_utf8/.dots/ferris.png" ) ) . exists ( ) ;
348334 Ok ( ( ) )
@@ -465,7 +451,7 @@ mod tests {
465451 vars. insert ( "name" , "Tom Bombadil" ) ;
466452
467453 // Act
468- dot. install ( & vars, vec ! [ ] ) ?;
454+ dot. install ( & vars, vec ! [ ] ) ?;
469455 let dot = PathBuf :: from ( ".dots/dotfiles/dot" ) ;
470456
471457 // Assert
@@ -533,7 +519,7 @@ mod tests {
533519 } ;
534520
535521 // Arrange
536- dot. install ( & Variables :: default ( ) , vec ! [ ] ) ?;
522+ dot. install ( & Variables :: default ( ) , vec ! [ ] ) ?;
537523
538524 // Assert
539525 let content = fs:: read_to_string ( PathBuf :: from (
0 commit comments