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:
Joe 2026-02-01 20:10:11 -06:00
parent 1534a54808
commit 411f79ee81
10 changed files with 232 additions and 65 deletions

View file

@ -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: "",
}],
);
}

View file

@ -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(

View file

@ -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.