@@ -368,26 +368,9 @@ fn cp_sources(
368368 let p = p. as_ref ( ) ;
369369 let relative = p. strip_prefix ( & src) . unwrap ( ) ;
370370
371- match relative. to_str ( ) {
372- // Skip git config files as they're not relevant to builds most of
373- // the time and if we respect them (e.g. in git) then it'll
374- // probably mess with the checksums when a vendor dir is checked
375- // into someone else's source control
376- Some ( ".gitattributes" | ".gitignore" | ".git" ) => continue ,
377-
378- // Temporary Cargo files
379- Some ( ".cargo-ok" ) => continue ,
380-
381- // Skip patch-style orig/rej files. Published crates on crates.io
382- // have `Cargo.toml.orig` which we don't want to use here and
383- // otherwise these are rarely used as part of the build process.
384- Some ( filename) => {
385- if filename. ends_with ( ".orig" ) || filename. ends_with ( ".rej" ) {
386- continue ;
387- }
388- }
389- _ => { }
390- } ;
371+ if !vendor_this ( relative) {
372+ continue ;
373+ }
391374
392375 // Join pathname components individually to make sure that the joined
393376 // path uses the correct directory separators everywhere, since
@@ -578,3 +561,25 @@ fn copy_and_checksum<T: Read>(
578561 . with_context ( || format ! ( "failed to write to {:?}" , dst_path) ) ?;
579562 }
580563}
564+
565+ /// Filters files we want to vendor.
566+ ///
567+ /// `relative` is a path relative to the package root.
568+ fn vendor_this ( relative : & Path ) -> bool {
569+ match relative. to_str ( ) {
570+ // Skip git config files as they're not relevant to builds most of
571+ // the time and if we respect them (e.g. in git) then it'll
572+ // probably mess with the checksums when a vendor dir is checked
573+ // into someone else's source control
574+ Some ( ".gitattributes" | ".gitignore" | ".git" ) => false ,
575+
576+ // Temporary Cargo files
577+ Some ( ".cargo-ok" ) => false ,
578+
579+ // Skip patch-style orig/rej files. Published crates on crates.io
580+ // have `Cargo.toml.orig` which we don't want to use here and
581+ // otherwise these are rarely used as part of the build process.
582+ Some ( p) if p. ends_with ( ".orig" ) || p. ends_with ( ".rej" ) => false ,
583+ _ => true ,
584+ }
585+ }
0 commit comments