Skip to content

Commit

Permalink
Merge pull request #901 from vrc-get/legacy-assets-and-guid
Browse files Browse the repository at this point in the history
chore: follow VCC 2.3.0 beta.3 VPM changes
  • Loading branch information
anatawa12 committed May 2, 2024
2 parents 04929a7 + 5fd8066 commit 4cc7d65
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-gui.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ The format is based on [Keep a Changelog].
- Issue Report button feature in Settings `#821`
- German translation `#824`
- SDK2 Project is now shown as type "SDK2" `#869`
- Legacy Assets are remove even if the specified GUID does not match with the actual GUID `#901`
- This follows VCC 2.3.0 beta 3 behavior.

### Changed

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog].
### Changed
- Relax validation for `package.json` for local user packages `#750`
- Improved handling for unlocked packages `#790`
- Legacy Assets are remove even if the specified GUID does not match with the actual GUID `#901`
- This follows VCC 2.3.0 beta 3 behavior.

### Deprecated

Expand Down
4 changes: 4 additions & 0 deletions vrc-get-vpm/src/unity_project/find_legacy_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ async fn find_legacy_assets_by_path<'a>(
}

async fn check_guid(io: &impl ProjectIo, path: &Path, guid: Option<Guid>) -> bool {
// for paths other than UdonSharp, we don't need to check the guid.
if path != Path::new("Assets/UdonSharp") {
return true;
}
if let Some(guid) = guid {
let mut path = OsString::from(path);
path.push(".meta");
Expand Down
73 changes: 62 additions & 11 deletions vrc-get-vpm/tests/add_package_to_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ fn deny_absolute_legacy_assets() {
}

#[test]
fn do_not_remove_legacy_files_that_guid_mismatches() {
fn do_remove_legacy_files_that_guid_mismatches() {
block_on(async {
let project = VirtualProjectBuilder::new()
.add_dir("Assets/LegacyGuidMismatchFolder")
Expand Down Expand Up @@ -754,8 +754,8 @@ fn do_not_remove_legacy_files_that_guid_mismatches() {
"Assets\\LegacyGuidMatchFolder",
"cbac8a2877e64d75af9b3b61fe946b40",
)
.add_legacy_folder(
"Packages\\LegacyGuidMismatchAsset.cs",
.add_legacy_file(
"Assets\\LegacyGuidMismatchAsset.cs",
"417a8085479b433792a67b2dfefb1982",
)
.add_legacy_file(
Expand Down Expand Up @@ -785,26 +785,77 @@ fn do_not_remove_legacy_files_that_guid_mismatches() {
.remove_legacy_folders()
.iter()
.collect::<HashSet<_>>(),
[(
Path::new("Assets/LegacyGuidMatchFolder").into(),
"com.anatawa12.package",
),]
[
(
Path::new("Assets/LegacyGuidMatchFolder").into(),
"com.anatawa12.package",
),
(
Path::new("Assets/LegacyGuidMismatchFolder").into(),
"com.anatawa12.package",
),
]
.iter()
.collect::<HashSet<_>>()
);

assert_eq!(
result.remove_legacy_files().iter().collect::<HashSet<_>>(),
[(
Path::new("Assets/LegacyGuidMatchAsset.cs").into(),
"com.anatawa12.package",
)]
[
(
Path::new("Assets/LegacyGuidMatchAsset.cs").into(),
"com.anatawa12.package",
),
(
Path::new("Assets/LegacyGuidMismatchAsset.cs").into(),
"com.anatawa12.package",
),
]
.iter()
.collect::<HashSet<_>>()
);
})
}

#[test]
fn do_not_remove_udonsharp_folder_if_guid_mismatch() {
block_on(async {
let project = VirtualProjectBuilder::new()
.add_dir("Assets/UdonSharp")
.add_file(
"Assets/UdonSharp.meta",
"guid: e2095dec983b4d9481723c263fd5b6c0",
)
.build()
.await
.unwrap();

let collection = PackageCollectionBuilder::new()
.add(
PackageManifest::new("com.vrchat.worlds", Version::new(1, 0, 0))
.add_legacy_folder("Assets\\UdonSharp", "b031f928e5c709b4887f6513084aaa51"),
)
.build();

let package = collection.get_package("com.vrchat.worlds", Version::new(1, 0, 0));

let result = project
.add_package_request(
&collection,
&[package],
AddPackageOperation::InstallToDependencies,
false,
)
.await
.unwrap();

assert_eq!(result.package_changes().len(), 1);
assert_eq!(result.conflicts().len(), 0);
assert_eq!(result.remove_legacy_folders().len(), 0);
assert_eq!(result.remove_legacy_files().len(), 0);
})
}

//endregion

// region errors
Expand Down

0 comments on commit 4cc7d65

Please sign in to comment.