Add automatic dedup suffix stripping to enhance syncback functionality

- Introduced a new plan to automatically strip `~N` dedup suffixes from filenames during forward sync, eliminating the need for redundant `.meta.json5` files.
- Implemented the `strip_dedup_suffix()` utility in `dedup_suffix.rs` to handle suffix removal.
- Updated `file_name_for_path()` and `get_dir_middleware()` to utilize the new stripping functionality.
- Modified syncback logic to skip writing meta `name` fields for dedup-only cases, ensuring cleaner instance naming.
- Enhanced existing tests and added new tests to cover the updated dedup behavior, ensuring robustness and correctness.

These changes aim to streamline the handling of deduplicated instances, improving overall system efficiency and clarity in naming conventions.
This commit is contained in:
Joe 2026-02-19 01:15:28 -06:00
parent 17d52e3edf
commit 7d0232c430
19 changed files with 269 additions and 84 deletions

View file

@ -0,0 +1,32 @@
---
source: tests/tests/build.rs
expression: contents
---
<roblox version="4">
<Item class="Folder" referent="0">
<Properties>
<string name="Name">dedup_suffix_auto_strip</string>
</Properties>
<Item class="ModuleScript" referent="1">
<Properties>
<string name="Name">Baz~0</string>
<string name="Source"><![CDATA[return "not a dedup suffix"
]]></string>
</Properties>
</Item>
<Item class="ModuleScript" referent="2">
<Properties>
<string name="Name">Foo</string>
<string name="Source"><![CDATA[return "first"
]]></string>
</Properties>
</Item>
<Item class="ModuleScript" referent="3">
<Properties>
<string name="Name">Foo</string>
<string name="Source"><![CDATA[return "second"
]]></string>
</Properties>
</Item>
</Item>
</roblox>

View file

@ -9,8 +9,8 @@ expression: contents
</Properties>
<Item class="ModuleScript" referent="1">
<Properties>
<string name="Name">Foo~1</string>
<string name="Source"><![CDATA[-- Tilde in filename without meta should produce instance name "Foo~1"
<string name="Name">Foo</string>
<string name="Source"><![CDATA[-- Dedup suffix ~1: forward sync strips it to produce instance name "Foo"
return nil
]]></string>
</Properties>

View file

@ -0,0 +1,6 @@
{
"name": "dedup_suffix_auto_strip",
"tree": {
"$path": "src"
}
}

View file

@ -0,0 +1 @@
return "not a dedup suffix"

View file

@ -0,0 +1 @@
return "first"

View file

@ -0,0 +1 @@
return "second"

View file

@ -1,2 +1,2 @@
-- Tilde in filename without meta should produce instance name "Foo~1"
-- Dedup suffix ~1: forward sync strips it to produce instance name "Foo"
return nil

View file

@ -12,7 +12,7 @@ body:
Id: id-13
Metadata:
ignoreUnknownInstances: false
Name: Foo~1
Name: Foo
Parent: id-3
Properties:
Source:

View file

@ -3,7 +3,7 @@ source: tests/rojo_test/syncback_util.rs
expression: normalized_stdout
---
Writing src/ChildWithDuplicates/DuplicateChild/.gitkeep
Writing src/ChildWithDuplicates/DuplicateChild~2/init.meta.json5
Writing src/ChildWithDuplicates/DuplicateChild~2/.gitkeep
Writing src/ChildWithoutDuplicates/Child/.gitkeep
Writing src/ChildWithDuplicates
Writing src/ChildWithDuplicates/DuplicateChild