mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Enhance syncback functionality and improve code readability
- Refactored the syncback process to streamline directory management and improve handling of class transitions in clean mode. - Updated the `clone_tree_filtered` function to accept a tuple of compiled Globs and original pattern strings, enhancing flexibility in ignore pattern handling. - Simplified logic for checking if paths are inside removed directories, improving code clarity. - Added detailed comments to clarify the purpose of new logic for handling script directory transitions, ensuring better maintainability. - Improved logging for better traceability during syncback operations.
This commit is contained in:
parent
1534a54808
commit
411f79ee81
10 changed files with 232 additions and 65 deletions
|
|
@ -53,10 +53,7 @@ pub fn run_rojo_build(project_path: &Path, output_name: &str) -> (TempDir, PathB
|
|||
pub fn run_rojo_syncback_clean(project_path: &Path, input_path: &Path) -> bool {
|
||||
// Verify input file exists before calling
|
||||
if !input_path.exists() {
|
||||
eprintln!(
|
||||
"ERROR: Input file does not exist: {}",
|
||||
input_path.display()
|
||||
);
|
||||
eprintln!("ERROR: Input file does not exist: {}", input_path.display());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +316,10 @@ pub fn apply_mutation(dir: &Path, mutation: &Mutation) {
|
|||
fs::remove_dir_all(&path).expect("Failed to delete directory");
|
||||
}
|
||||
}
|
||||
Mutation::ConvertDirToFile { dir: dir_path, file_content } => {
|
||||
Mutation::ConvertDirToFile {
|
||||
dir: dir_path,
|
||||
file_content,
|
||||
} => {
|
||||
let path = dir.join(dir_path);
|
||||
if path.exists() && path.is_dir() {
|
||||
fs::remove_dir_all(&path).expect("Failed to remove directory");
|
||||
|
|
|
|||
|
|
@ -521,12 +521,10 @@ fn clean_handles_empty_orphan_directory() {
|
|||
// with just adding an empty-ish directory structure
|
||||
clean_equals_fresh(
|
||||
"deep_nesting",
|
||||
&[
|
||||
Mutation::AddOrphanFile {
|
||||
relative_path: "src/empty_dir/.gitkeep",
|
||||
content: "",
|
||||
},
|
||||
],
|
||||
&[Mutation::AddOrphanFile {
|
||||
relative_path: "src/empty_dir/.gitkeep",
|
||||
content: "",
|
||||
}],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -335,10 +335,16 @@ fn standalone_module_sync_adding_children_converts_to_directory() {
|
|||
send_write_request(&session, &info.session_id, rs_id, added);
|
||||
|
||||
// Standalone file should be removed (converted to directory)
|
||||
assert_not_exists(&standalone_file, "Standalone file should be removed after conversion");
|
||||
assert_not_exists(
|
||||
&standalone_file,
|
||||
"Standalone file should be removed after conversion",
|
||||
);
|
||||
|
||||
// Directory should be created with init file
|
||||
assert_directory_exists(&dir_path, "Directory should be created for script with children");
|
||||
assert_directory_exists(
|
||||
&dir_path,
|
||||
"Directory should be created for script with children",
|
||||
);
|
||||
let init_file = dir_path.join("init.luau");
|
||||
assert_file_exists(&init_file, "init.luau should exist");
|
||||
|
||||
|
|
@ -388,10 +394,16 @@ fn standalone_script_sync_adding_children_converts_to_directory() {
|
|||
send_write_request(&session, &info.session_id, rs_id, added);
|
||||
|
||||
// Standalone file should be removed (converted to directory)
|
||||
assert_not_exists(&standalone_file, "Standalone file should be removed after conversion");
|
||||
assert_not_exists(
|
||||
&standalone_file,
|
||||
"Standalone file should be removed after conversion",
|
||||
);
|
||||
|
||||
// Directory should be created with init file
|
||||
assert_directory_exists(&dir_path, "Directory should be created for script with children");
|
||||
assert_directory_exists(
|
||||
&dir_path,
|
||||
"Directory should be created for script with children",
|
||||
);
|
||||
let init_file = dir_path.join("init.server.luau");
|
||||
assert_file_exists(&init_file, "init.server.luau should exist");
|
||||
|
||||
|
|
@ -442,10 +454,16 @@ fn standalone_localscript_sync_adding_children_converts_to_directory() {
|
|||
send_write_request(&session, &info.session_id, rs_id, added);
|
||||
|
||||
// Standalone file should be removed (converted to directory)
|
||||
assert_not_exists(&standalone_file, "Standalone file should be removed after conversion");
|
||||
assert_not_exists(
|
||||
&standalone_file,
|
||||
"Standalone file should be removed after conversion",
|
||||
);
|
||||
|
||||
// Directory should be created with init file
|
||||
assert_directory_exists(&dir_path, "Directory should be created for script with children");
|
||||
assert_directory_exists(
|
||||
&dir_path,
|
||||
"Directory should be created for script with children",
|
||||
);
|
||||
let init_file = dir_path.join("init.local.luau");
|
||||
assert_file_exists(&init_file, "init.local.luau should exist");
|
||||
|
||||
|
|
@ -2066,7 +2084,10 @@ fn sync_standalone_then_directory_format() {
|
|||
send_write_request(&session, &info.session_id, rs_id, added1);
|
||||
|
||||
// Standalone should still exist after sync without children
|
||||
assert_file_exists(&standalone, "Standalone preserved after sync without children");
|
||||
assert_file_exists(
|
||||
&standalone,
|
||||
"Standalone preserved after sync without children",
|
||||
);
|
||||
|
||||
// Second sync - with children (converts to directory)
|
||||
let added2 = make_added_instance(
|
||||
|
|
|
|||
|
|
@ -75,11 +75,16 @@ fn assert_rbx_equal(file_a: &Path, file_b: &Path, test_name: &str) {
|
|||
let data_b = fs::read(file_b).expect("Failed to read roundtrip rbxl");
|
||||
|
||||
let dom_a = rbx_binary::from_reader(data_a.as_slice()).expect("Failed to parse original rbxl");
|
||||
let dom_b =
|
||||
rbx_binary::from_reader(data_b.as_slice()).expect("Failed to parse roundtrip rbxl");
|
||||
let dom_b = rbx_binary::from_reader(data_b.as_slice()).expect("Failed to parse roundtrip rbxl");
|
||||
|
||||
// Compare the root's children (DataModel children)
|
||||
compare_children(&dom_a, dom_a.root_ref(), &dom_b, dom_b.root_ref(), test_name);
|
||||
compare_children(
|
||||
&dom_a,
|
||||
dom_a.root_ref(),
|
||||
&dom_b,
|
||||
dom_b.root_ref(),
|
||||
test_name,
|
||||
);
|
||||
}
|
||||
|
||||
/// Recursively compare children of two instances.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue