diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-03 10:54:36 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-03 10:54:36 +0900 |
| commit | c865a24596084eec90d10860265748c93bf7eb6a (patch) | |
| tree | e22f32c6560a37ab245e3458fe3b69d89996e415 /crates/mozart-sat-resolver/src/pool_builder.rs | |
| parent | b60cf8d9cb6776e5df85f080b5bb3fba252e154c (diff) | |
| download | php-mozart-c865a24596084eec90d10860265748c93bf7eb6a.tar.gz php-mozart-c865a24596084eec90d10860265748c93bf7eb6a.tar.zst php-mozart-c865a24596084eec90d10860265748c93bf7eb6a.zip | |
fix(resolver): substitute self.version in pool link constraints
Composer's ArrayLoader and AliasPackage rewrite "self.version" to the
declaring package's own version when building Link objects, so a
package's replace/provide/conflict/require constraints carry a concrete
"= <version>" rather than the literal string. Mozart was passing
"self.version" through verbatim, which then failed to parse in
Pool::matches_package and caused replace_alias.test to fail to find a
provider for c/c 1.* via a/a's branch alias.
Push the substitution into make_pool_links, threading the source
package's normalized version through the call sites in resolver.rs
(packagist/inline/composer-repo) and vcs_bridge.rs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-sat-resolver/src/pool_builder.rs')
| -rw-r--r-- | crates/mozart-sat-resolver/src/pool_builder.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/crates/mozart-sat-resolver/src/pool_builder.rs b/crates/mozart-sat-resolver/src/pool_builder.rs index 94bbf4c..83684aa 100644 --- a/crates/mozart-sat-resolver/src/pool_builder.rs +++ b/crates/mozart-sat-resolver/src/pool_builder.rs @@ -120,11 +120,24 @@ impl Default for PoolBuilder { } /// Helper to convert (name, constraint) pairs from Packagist into PoolLinks. -pub fn make_pool_links(source: &str, deps: &[(String, String)]) -> Vec<PoolLink> { +/// +/// `source_version` is the normalized version of the package declaring these +/// links; it replaces any `"self.version"` constraint, mirroring Composer's +/// `ArrayLoader::createLink` (and `AliasPackage::replaceSelfVersionDependencies`, +/// which feeds the alias's own version in for the same purpose). +pub fn make_pool_links( + source: &str, + source_version: &str, + deps: &[(String, String)], +) -> Vec<PoolLink> { deps.iter() .map(|(target, constraint)| PoolLink { target: target.clone(), - constraint: constraint.clone(), + constraint: if constraint.trim() == "self.version" { + source_version.to_string() + } else { + constraint.clone() + }, source: source.to_string(), }) .collect() |
