diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-01 20:14:53 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-01 20:14:53 +0900 |
| commit | 8261abde3d9fb9ec1d764b912fa5487e4fcd9339 (patch) | |
| tree | 55ebfda66f4394e0185c2de7c4ca9ac973892eb8 /crates/mozart-core/src/package.rs | |
| parent | 1189cecc564c691afeee564203866570fe6928b1 (diff) | |
| download | php-mozart-8261abde3d9fb9ec1d764b912fa5487e4fcd9339.tar.gz php-mozart-8261abde3d9fb9ec1d764b912fa5487e4fcd9339.tar.zst php-mozart-8261abde3d9fb9ec1d764b912fa5487e4fcd9339.zip | |
fix(core): default missing composer.json "name" to __root__
Composer's RootPackageLoader assigns the root name "__root__" when
composer.json omits the "name" field. Mozart was failing deserialization
in that case, blocking any installer fixture with a nameless root
manifest. Apply the same serde default and unignore
update-to-empty-from-blank as the first green entry on the .test
scoreboard.
Diffstat (limited to 'crates/mozart-core/src/package.rs')
| -rw-r--r-- | crates/mozart-core/src/package.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/mozart-core/src/package.rs b/crates/mozart-core/src/package.rs index ce2ff12..5906c7e 100644 --- a/crates/mozart-core/src/package.rs +++ b/crates/mozart-core/src/package.rs @@ -458,6 +458,7 @@ delegate_complete_package!(RootPackageData => complete); /// and map directly to the JSON keys via serde. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct RawPackageData { + #[serde(default = "default_root_package_name")] pub name: String, #[serde(skip_serializing_if = "Option::is_none")] @@ -531,6 +532,12 @@ pub struct RawRepository { pub url: String, } +/// Default root-package name when `composer.json` omits the `name` field. +/// Mirrors Composer's `RootPackageLoader` fallback. +fn default_root_package_name() -> String { + "__root__".to_string() +} + impl RawPackageData { pub fn new(name: String) -> Self { Self { |
