mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Refactor code for improved readability and consistency
- Simplified the formatting of path handling in `change_processor.rs` and `fs_snapshot.rs` by consolidating multiple lines into single lines for better clarity. - Updated test assertions in `two_way_sync.rs` to streamline the code and enhance maintainability. These changes enhance the overall readability of the codebase, making it easier to manage and understand.
This commit is contained in:
parent
cc2c828757
commit
85787f3452
4 changed files with 17 additions and 21 deletions
|
|
@ -1236,19 +1236,15 @@ impl JobThreadContext {
|
||||||
// is dir/init.luau; the dir was
|
// is dir/init.luau; the dir was
|
||||||
// renamed so update the dir
|
// renamed so update the dir
|
||||||
// portion.
|
// portion.
|
||||||
let init_name = old_path
|
let init_name =
|
||||||
.file_name()
|
old_path.file_name().unwrap().to_str().unwrap();
|
||||||
.unwrap()
|
|
||||||
.to_str()
|
|
||||||
.unwrap();
|
|
||||||
to.join(init_name)
|
to.join(init_name)
|
||||||
} else {
|
} else {
|
||||||
// Standalone file: new source
|
// Standalone file: new source
|
||||||
// IS the `to` path.
|
// IS the `to` path.
|
||||||
to.clone()
|
to.clone()
|
||||||
};
|
};
|
||||||
dedup_metadata_updates
|
dedup_metadata_updates.push((sibling_ref, new_source));
|
||||||
.push((sibling_ref, new_source));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -538,7 +538,12 @@ mod tests {
|
||||||
let substitutions = vec![("Workspace/Foo".to_string(), "Workspace/Foo~1".to_string())];
|
let substitutions = vec![("Workspace/Foo".to_string(), "Workspace/Foo~1".to_string())];
|
||||||
snap.fix_ref_paths(&substitutions);
|
snap.fix_ref_paths(&substitutions);
|
||||||
|
|
||||||
let result = std::str::from_utf8(snap.added_files.get(Path::new("/test/init.meta.json5")).unwrap()).unwrap();
|
let result = std::str::from_utf8(
|
||||||
|
snap.added_files
|
||||||
|
.get(Path::new("/test/init.meta.json5"))
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
result.contains(r#""Rojo_Ref_PrimaryPart": "Workspace/Foo~1""#),
|
result.contains(r#""Rojo_Ref_PrimaryPart": "Workspace/Foo~1""#),
|
||||||
|
|
@ -564,7 +569,12 @@ mod tests {
|
||||||
let substitutions = vec![("Workspace/Foo".to_string(), "Workspace/Foo~1".to_string())];
|
let substitutions = vec![("Workspace/Foo".to_string(), "Workspace/Foo~1".to_string())];
|
||||||
snap.fix_ref_paths(&substitutions);
|
snap.fix_ref_paths(&substitutions);
|
||||||
|
|
||||||
let result = std::str::from_utf8(snap.added_files.get(Path::new("/test/script.luau")).unwrap()).unwrap();
|
let result = std::str::from_utf8(
|
||||||
|
snap.added_files
|
||||||
|
.get(Path::new("/test/script.luau"))
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
result.contains("Workspace/Foo"),
|
result.contains("Workspace/Foo"),
|
||||||
"Non-meta file should not be touched. Got: {}",
|
"Non-meta file should not be touched. Got: {}",
|
||||||
|
|
|
||||||
|
|
@ -3574,13 +3574,7 @@ fn added_instance_fs_segment(added: &crate::web::interface::AddedInstance) -> St
|
||||||
|
|
||||||
let is_container = matches!(
|
let is_container = matches!(
|
||||||
added.class_name.as_str(),
|
added.class_name.as_str(),
|
||||||
"Folder"
|
"Folder" | "Configuration" | "Tool" | "ScreenGui" | "SurfaceGui" | "BillboardGui" | "AdGui"
|
||||||
| "Configuration"
|
|
||||||
| "Tool"
|
|
||||||
| "ScreenGui"
|
|
||||||
| "SurfaceGui"
|
|
||||||
| "BillboardGui"
|
|
||||||
| "AdGui"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let is_script = matches!(
|
let is_script = matches!(
|
||||||
|
|
|
||||||
|
|
@ -7374,10 +7374,6 @@ fn ref_same_batch_add_folder_target_no_extension() {
|
||||||
let meta_path = session
|
let meta_path = session
|
||||||
.path()
|
.path()
|
||||||
.join("src/Workspace/TestModel/init.meta.json5");
|
.join("src/Workspace/TestModel/init.meta.json5");
|
||||||
poll_meta_has_ref_attr(
|
poll_meta_has_ref_attr(&meta_path, "Rojo_Ref_PrimaryPart", "Workspace/FolderTarget");
|
||||||
&meta_path,
|
|
||||||
"Rojo_Ref_PrimaryPart",
|
|
||||||
"Workspace/FolderTarget",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue