@@ -351,6 +351,20 @@ fn execute_zip(
351351 let zip_file_path = zip_dir. join ( format ! ( "{}.zip" , exercise. name) ) ;
352352
353353 let mut writer = zip:: ZipWriter :: new ( file_util:: create_file ( zip_file_path) ?) ;
354+
355+ // hidden files are filtered, so we handle .tmcproject.yml here
356+ let tmcproject_yml_path = exercise_root. join ( ".tmcproject.yml" ) ;
357+ if tmcproject_yml_path. exists ( ) {
358+ let tmcproject_yml = file_util:: read_file ( & tmcproject_yml_path) ?;
359+ let relative_path = tmcproject_yml_path. strip_prefix ( & root_path) . unwrap ( ) ; // safe
360+ writer. start_file (
361+ relative_path. to_string_lossy ( ) ,
362+ zip:: write:: FileOptions :: default ( ) ,
363+ ) ?;
364+ writer
365+ . write_all ( & tmcproject_yml)
366+ . map_err ( LangsError :: ZipWrite ) ?;
367+ }
354368 for entry in WalkDir :: new ( & exercise_root) . into_iter ( ) . filter_entry ( |e| {
355369 !e. file_name ( )
356370 . to_str ( )
@@ -530,12 +544,14 @@ mod test {
530544 file_to ( & temp, "clone/part2/ex2/setup.py" , "" ) ;
531545 file_to ( & temp, "clone/part2/ex2/dir/subdir/file" , "" ) ;
532546 file_to ( & temp, "clone/part2/ex2/dir/subdir/.hidden" , "" ) ;
547+ file_to ( & temp, "clone/part2/ex2/.tmcproject.yml" , "some: 'yaml'" ) ;
533548 file_to ( & temp, "stub/part1/ex1/setup.py" , "" ) ;
534549 file_to ( & temp, "stub/part1/ex2/setup.py" , "" ) ;
535550 file_to ( & temp, "stub/part2/ex1/setup.py" , "" ) ;
536551 file_to ( & temp, "stub/part2/ex2/setup.py" , "" ) ;
537552 file_to ( & temp, "stub/part2/ex2/dir/subdir/file" , "some file" ) ;
538553 file_to ( & temp, "stub/part2/ex2/dir/subdir/.hidden" , "hidden file" ) ;
554+ file_to ( & temp, "stub/part2/ex2/.tmcproject.yml" , "some: 'yaml'" ) ;
539555
540556 let exercise_dirs = find_exercise_directories ( & temp. path ( ) . join ( "clone" ) )
541557 . unwrap ( )
@@ -603,7 +619,20 @@ mod test {
603619 . unwrap ( ) ; // other files have their stub contents
604620 let mut buf = String :: new ( ) ;
605621 file. read_to_string ( & mut buf) . unwrap ( ) ;
622+ drop ( file) ;
623+
606624 assert_eq ! ( buf, "some file" ) ;
625+ let mut file = fz
626+ . by_name (
627+ & Path :: new ( "part2" )
628+ . join ( "ex2" )
629+ . join ( ".tmcproject.yml" )
630+ . to_string_lossy ( ) ,
631+ )
632+ . unwrap ( ) ; // .tmcproject.yml is not filtered out
633+ let mut buf = String :: new ( ) ;
634+ file. read_to_string ( & mut buf) . unwrap ( ) ;
635+ assert_eq ! ( buf, "some: 'yaml'" ) ;
607636 }
608637
609638 #[ test]
0 commit comments