@@ -147,6 +147,8 @@ impl<'cfg> PathSource<'cfg> {
147
147
if let Some ( result) = self . discover_git_and_list_files ( pkg, root, & mut filter) {
148
148
return result;
149
149
}
150
+ // no include option and not git repo discovered (see rust-lang/cargo#7183).
151
+ return self . list_files_walk_except_dot_files_and_dirs ( pkg, & mut filter) ;
150
152
}
151
153
self . list_files_walk ( pkg, & mut filter)
152
154
}
@@ -329,6 +331,29 @@ impl<'cfg> PathSource<'cfg> {
329
331
}
330
332
}
331
333
334
+ fn list_files_walk_except_dot_files_and_dirs (
335
+ & self ,
336
+ pkg : & Package ,
337
+ filter : & mut dyn FnMut ( & Path ) -> CargoResult < bool > ,
338
+ ) -> CargoResult < Vec < PathBuf > > {
339
+ let root = pkg. root ( ) ;
340
+ let mut exclude_dot_files_dir_builder = GitignoreBuilder :: new ( root) ;
341
+ exclude_dot_files_dir_builder. add_line ( None , ".*" ) ?;
342
+ exclude_dot_files_dir_builder. add_line ( None , "*/.*/*" ) ?;
343
+ let ignore_dot_files_and_dirs = exclude_dot_files_dir_builder. build ( ) ?;
344
+
345
+ let mut filter_ignore_dot_files_and_dirs = |path : & Path | -> CargoResult < bool > {
346
+ let relative_path = path. strip_prefix ( root) ?;
347
+ match ignore_dot_files_and_dirs
348
+ . matched_path_or_any_parents ( relative_path, /* is_dir */ false )
349
+ {
350
+ Match :: Ignore ( _) => Ok ( false ) ,
351
+ _ => filter ( path) ,
352
+ }
353
+ } ;
354
+ self . list_files_walk ( pkg, & mut filter_ignore_dot_files_and_dirs)
355
+ }
356
+
332
357
fn list_files_walk (
333
358
& self ,
334
359
pkg : & Package ,
@@ -355,15 +380,6 @@ impl<'cfg> PathSource<'cfg> {
355
380
if !is_root && fs:: metadata ( & path. join ( "Cargo.toml" ) ) . is_ok ( ) {
356
381
return Ok ( ( ) ) ;
357
382
}
358
- // Skip dotfile directories.
359
- if path
360
- . file_name ( )
361
- . and_then ( |s| s. to_str ( ) )
362
- . map ( |s| s. starts_with ( '.' ) )
363
- == Some ( true )
364
- {
365
- return Ok ( ( ) ) ;
366
- }
367
383
368
384
// For package integration tests, we need to sort the paths in a deterministic order to
369
385
// be able to match stdout warnings in the same order.
0 commit comments