@@ -769,27 +769,32 @@ fn extract_mutable_package_sources(output: &Output) -> Option<Vec<PathBuf>> {
769769
770770/// Returns the relative path from `base` to `input`, joined by "/".
771771fn build_relative_glob ( base : & std:: path:: Path , input : & std:: path:: Path ) -> miette:: Result < String > {
772+ // Get the difference between paths
772773 let rel = pathdiff:: diff_paths ( input, base) . ok_or_else ( || {
773774 miette:: miette!(
774775 "could not compute relative path from '{:?}' to '{:?}'" ,
775776 input,
776777 base
777778 )
778779 } ) ?;
780+
781+ // Normalize the path
779782 let joined = rel
780783 . components ( )
781784 . map ( |c| c. as_os_str ( ) . to_string_lossy ( ) )
782785 . collect :: < Vec < _ > > ( )
783786 . join ( "/" ) ;
784787
785788 if input. is_dir ( ) {
786- let dir_glob = if joined. is_empty ( ) {
787- "*" . to_string ( )
789+ // This means the base is the same as the input
790+ // just use `**` in that case that matches everything
791+ if joined. is_empty ( ) {
792+ Ok ( "**" . to_string ( ) )
788793 } else {
789- joined
790- } ;
791- Ok ( format ! ( "{}/**" , dir_glob) )
794+ Ok ( format ! ( "{joined}/**" ) )
795+ }
792796 } else {
797+ // This is a file so lets just use that
793798 Ok ( joined)
794799 }
795800}
@@ -801,7 +806,7 @@ fn build_input_globs(
801806 extra_globs : Vec < String > ,
802807) -> miette:: Result < BTreeSet < String > > {
803808 // Get parent directory path
804- let parent = if source. is_file ( ) {
809+ let src_parent = if source. is_file ( ) {
805810 // use the parent path as glob
806811 source. parent ( ) . unwrap_or ( source) . to_path_buf ( )
807812 } else {
@@ -810,15 +815,15 @@ fn build_input_globs(
810815 } ;
811816
812817 // Always add the current directory of the package to the globs
813- let mut input_globs = BTreeSet :: from ( [ build_relative_glob ( manifest_root, & parent ) ?] ) ;
818+ let mut input_globs = BTreeSet :: from ( [ build_relative_glob ( manifest_root, & src_parent ) ?] ) ;
814819
815820 // If there are sources add them to the globs as well
816821 if let Some ( package_sources) = package_sources {
817822 for source in package_sources {
818823 let source = if source. is_absolute ( ) {
819824 source
820825 } else {
821- parent . join ( source)
826+ src_parent . join ( source)
822827 } ;
823828 input_globs. insert ( build_relative_glob ( manifest_root, & source) ?) ;
824829 }
@@ -1229,7 +1234,7 @@ mod tests {
12291234 let recipe_path = base_path. join ( "recipe.yaml" ) ;
12301235 fs:: write ( & recipe_path, "fake" ) . unwrap ( ) ;
12311236 let globs = super :: build_input_globs ( base_path, & recipe_path, None , Vec :: new ( ) ) . unwrap ( ) ;
1232- assert_eq ! ( globs, BTreeSet :: from( [ String :: from( "*/* *" ) ] ) ) ;
1237+ assert_eq ! ( globs, BTreeSet :: from( [ String :: from( "**" ) ] ) ) ;
12331238
12341239 // Case 2: source is a directory, with a file and a dir as package sources
12351240 let pkg_dir = base_path. join ( "pkg" ) ;
@@ -1247,7 +1252,7 @@ mod tests {
12471252 assert_eq ! (
12481253 globs,
12491254 BTreeSet :: from( [
1250- String :: from( "*/* *" ) ,
1255+ String :: from( "**" ) ,
12511256 String :: from( "pkg/file.txt" ) ,
12521257 String :: from( "pkg/dir/**" )
12531258 ] )
@@ -1312,11 +1317,7 @@ mod tests {
13121317 // The relative path from base_path to rel_dir should be "rel_folder/**"
13131318 assert_eq ! (
13141319 globs,
1315- BTreeSet :: from_iter(
1316- [ "*/**" , "rel_folder/**" ]
1317- . into_iter( )
1318- . map( ToString :: to_string)
1319- )
1320+ BTreeSet :: from_iter( [ "**" , "rel_folder/**" ] . into_iter( ) . map( ToString :: to_string) )
13201321 ) ;
13211322 }
13221323
@@ -1332,7 +1333,7 @@ mod tests {
13321333 let manifest_root = PathBuf :: from ( "/" ) ;
13331334 let path = PathBuf :: from ( "/" ) ;
13341335 let globs = super :: get_metadata_input_globs ( & manifest_root, & path) . unwrap ( ) ;
1335- assert_eq ! ( globs, BTreeSet :: from( [ String :: from( "*/* *" ) ] ) ) ;
1336+ assert_eq ! ( globs, BTreeSet :: from( [ String :: from( "**" ) ] ) ) ;
13361337 // Case: file with .yml extension
13371338 let manifest_root = PathBuf :: from ( "/foo/bar" ) ;
13381339 let path = PathBuf :: from ( "/foo/bar/recipe.yml" ) ;
@@ -1374,6 +1375,6 @@ mod tests {
13741375 }
13751376
13761377 // Verify that the basic manifest glob is still present
1377- assert ! ( globs. contains( "*/* *" ) ) ;
1378+ assert ! ( globs. contains( "**" ) ) ;
13781379 }
13791380}
0 commit comments