Skip to content

Commit d7e83c5

Browse files
authored
Merge pull request #146 from rage/merge-change
fixed merge and made it so merged configs are only saved to stub and …
2 parents d3c2cf6 + 2dc51db commit d7e83c5

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

tmc-langs-framework/src/tmc_project_yml.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ impl TmcProjectYml {
101101
if self.minimum_python_version.is_none() {
102102
self.minimum_python_version = with.minimum_python_version;
103103
}
104+
if self.sandbox_image.is_none() {
105+
self.sandbox_image = with.sandbox_image;
106+
}
104107
}
105108

106109
pub fn save_to_dir(&self, dir: &Path) -> Result<(), TmcError> {

tmc-langs/src/course_refresher.rs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,25 @@ pub fn refresh_course(
9696

9797
// make_solutions
9898
log::info!("preparing solutions to {}", new_solution_path.display());
99-
for (exercise, _) in &exercise_dirs_and_tmcprojects {
100-
super::prepare_solution(
101-
&new_clone_path.join(&exercise),
102-
&new_solution_path.join(&exercise),
103-
)?;
99+
for (exercise, merged_tmcproject) in &exercise_dirs_and_tmcprojects {
100+
// save merged config to solution
101+
let dest_root = new_solution_path.join(&exercise);
102+
super::prepare_solution(&new_clone_path.join(&exercise), &dest_root)?;
103+
if let Some(merged_tmcproject) = merged_tmcproject {
104+
merged_tmcproject.save_to_dir(&dest_root)?;
105+
}
104106
}
105107
progress_stage("Prepared solutions");
106108

107109
// make_stubs
108110
log::info!("preparing stubs to {}", new_stub_path.display());
109-
for (exercise, _) in &exercise_dirs_and_tmcprojects {
110-
super::prepare_stub(
111-
&new_clone_path.join(&exercise),
112-
&new_stub_path.join(&exercise),
113-
)?;
111+
for (exercise, merged_tmcproject) in &exercise_dirs_and_tmcprojects {
112+
// save merged config to stub
113+
let dest_root = new_stub_path.join(&exercise);
114+
super::prepare_stub(&new_clone_path.join(&exercise), &dest_root)?;
115+
if let Some(merged_tmcproject) = merged_tmcproject {
116+
merged_tmcproject.save_to_dir(&dest_root)?;
117+
}
114118
}
115119
progress_stage("Prepared stubs");
116120

@@ -239,11 +243,9 @@ fn get_and_merge_tmcproject_configs(
239243
match (&root_tmcproject, exercise_tmcproject) {
240244
(Some(root), Some(mut exercise)) => {
241245
exercise.merge(root.clone());
242-
exercise.save_to_dir(&target_dir)?;
243246
res.push((exercise_dir, Some(exercise)));
244247
}
245248
(Some(root), None) => {
246-
root.save_to_dir(&target_dir)?;
247249
res.push((exercise_dir, Some(root.clone())));
248250
}
249251
(None, Some(exercise)) => res.push((exercise_dir, Some(exercise))),
@@ -668,13 +670,22 @@ mod test {
668670
tpyb.save_to_dir(&exbp_path).unwrap();
669671
let exercise_dirs = vec![exap, exbp];
670672

671-
get_and_merge_tmcproject_configs(Some(root), temp.path(), exercise_dirs).unwrap();
673+
let dirs_configs =
674+
get_and_merge_tmcproject_configs(Some(root), temp.path(), exercise_dirs).unwrap();
672675

673-
let tpya = TmcProjectYml::load(&exap_path).unwrap().unwrap();
676+
let (_, tpya) = &dirs_configs
677+
.iter()
678+
.find(|(p, _)| p.ends_with("exa"))
679+
.unwrap();
680+
let tpya = tpya.as_ref().unwrap();
674681
assert_eq!(tpya.tests_timeout_ms, Some(2345));
675682
assert_eq!(tpya.fail_on_valgrind_error, Some(true));
676683

677-
let tpyb = TmcProjectYml::load(&exbp_path).unwrap().unwrap();
684+
let (_, tpyb) = &dirs_configs
685+
.iter()
686+
.find(|(p, _)| p.ends_with("exb"))
687+
.unwrap();
688+
let tpyb = tpyb.as_ref().unwrap();
678689
assert_eq!(tpyb.tests_timeout_ms, Some(1234));
679690
assert_eq!(tpyb.fail_on_valgrind_error, Some(false));
680691
}

0 commit comments

Comments
 (0)