@@ -351,6 +351,20 @@ fn execute_zip(
351
351
let zip_file_path = zip_dir. join ( format ! ( "{}.zip" , exercise. name) ) ;
352
352
353
353
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
+ }
354
368
for entry in WalkDir :: new ( & exercise_root) . into_iter ( ) . filter_entry ( |e| {
355
369
!e. file_name ( )
356
370
. to_str ( )
@@ -530,12 +544,14 @@ mod test {
530
544
file_to ( & temp, "clone/part2/ex2/setup.py" , "" ) ;
531
545
file_to ( & temp, "clone/part2/ex2/dir/subdir/file" , "" ) ;
532
546
file_to ( & temp, "clone/part2/ex2/dir/subdir/.hidden" , "" ) ;
547
+ file_to ( & temp, "clone/part2/ex2/.tmcproject.yml" , "some: 'yaml'" ) ;
533
548
file_to ( & temp, "stub/part1/ex1/setup.py" , "" ) ;
534
549
file_to ( & temp, "stub/part1/ex2/setup.py" , "" ) ;
535
550
file_to ( & temp, "stub/part2/ex1/setup.py" , "" ) ;
536
551
file_to ( & temp, "stub/part2/ex2/setup.py" , "" ) ;
537
552
file_to ( & temp, "stub/part2/ex2/dir/subdir/file" , "some file" ) ;
538
553
file_to ( & temp, "stub/part2/ex2/dir/subdir/.hidden" , "hidden file" ) ;
554
+ file_to ( & temp, "stub/part2/ex2/.tmcproject.yml" , "some: 'yaml'" ) ;
539
555
540
556
let exercise_dirs = find_exercise_directories ( & temp. path ( ) . join ( "clone" ) )
541
557
. unwrap ( )
@@ -603,7 +619,20 @@ mod test {
603
619
. unwrap ( ) ; // other files have their stub contents
604
620
let mut buf = String :: new ( ) ;
605
621
file. read_to_string ( & mut buf) . unwrap ( ) ;
622
+ drop ( file) ;
623
+
606
624
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'" ) ;
607
636
}
608
637
609
638
#[ test]
0 commit comments