diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-04 09:54:09 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-04 09:54:09 +0900 |
| commit | ba1463ea86ad25b910fff13d8527ac2c0f661ab4 (patch) | |
| tree | dac1281ae1da05eb2600ef0432f859393c2a5187 /crates | |
| parent | f7b87d6934ea05d35e3ee0576e7d82d3b67b001e (diff) | |
| download | php-mozart-ba1463ea86ad25b910fff13d8527ac2c0f661ab4.tar.gz php-mozart-ba1463ea86ad25b910fff13d8527ac2c0f661ab4.tar.zst php-mozart-ba1463ea86ad25b910fff13d8527ac2c0f661ab4.zip | |
fix(resolver): expose locked branch-alias entries in the pool
Composer's Locker::getLockedRepository runs each locked package through
ArrayLoader::load, which materializes any extra.branch-alias as a
separate AliasPackage in the locked repository. Mozart was only adding
the base locked package to the pool, so a `dev-master` locked entry
with branch alias `2.2.x-dev` was invisible to numeric root constraints
like `~2.1` on a partial update — the resolver bailed with "no matching
package found" even though Composer accepts the same lock. Surface
each branch-alias as a sibling pool entry pointing at the base via
is_alias_of.
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/mozart-registry/src/resolver.rs | 20 | ||||
| -rw-r--r-- | crates/mozart/tests/installer.rs | 2 |
2 files changed, 21 insertions, 1 deletions
diff --git a/crates/mozart-registry/src/resolver.rs b/crates/mozart-registry/src/resolver.rs index 87a92e9..5dbe74f 100644 --- a/crates/mozart-registry/src/resolver.rs +++ b/crates/mozart-registry/src/resolver.rs @@ -1165,6 +1165,26 @@ pub async fn resolve(request: &ResolveRequest) -> Result<Vec<ResolvedPackage>, R is_alias_of: None, }; builder.add_package(input); + // Also expose each `extra.branch-alias` entry as a separate pool + // package, mirroring `Composer\Package\Locker::getLockedRepository` + // (which calls `ArrayLoader::load`, which materializes the + // branch-alias via `getBranchAlias`). Without this, a `dev-master` + // locked package with branch alias `2.2.x-dev` is only visible + // under `dev-master` in the pool, so root requires like `~2.1` + // see no candidate and the resolver fails on a partial update. + for (alias_pretty, alias_normalized) in &locked.branch_aliases { + builder.add_package(PoolPackageInput { + name: locked_name_lower.clone(), + version: alias_normalized.clone(), + pretty_version: alias_pretty.clone(), + requires: make_pool_links(&locked_name_lower, alias_normalized, &locked.requires), + replaces: make_pool_links(&locked_name_lower, alias_normalized, &locked.replaces), + provides: make_pool_links(&locked_name_lower, alias_normalized, &locked.provides), + conflicts: make_pool_links(&locked_name_lower, alias_normalized, &locked.conflicts), + is_fixed: false, + is_alias_of: Some(locked.version_normalized.clone()), + }); + } } // Scan VCS repositories and collect packages from them diff --git a/crates/mozart/tests/installer.rs b/crates/mozart/tests/installer.rs index 729e9db..b1c1968 100644 --- a/crates/mozart/tests/installer.rs +++ b/crates/mozart/tests/installer.rs @@ -314,7 +314,7 @@ installer_fixture!(partial_update_downgrades_non_allow_listed_unstable); installer_fixture!(partial_update_forces_dev_reference_from_lock_for_non_updated_packages); installer_fixture!(partial_update_from_lock); installer_fixture!(partial_update_from_lock_with_root_alias); -installer_fixture!(partial_update_installs_from_lock_even_missing, ignore); +installer_fixture!(partial_update_installs_from_lock_even_missing); installer_fixture!(partial_update_keeps_older_dep_if_still_required); installer_fixture!(partial_update_keeps_older_dep_if_still_required_with_provide); installer_fixture!(partial_update_loads_root_aliases_for_path_repos); |
