aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands/install.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-03 19:19:40 +0900
committernsfisis <nsfisis@gmail.com>2026-05-03 19:19:40 +0900
commit240b0dd14a607a9dfdb84bb339c87bb0effd6963 (patch)
tree7fee0768e90360bb8fd6368d642e9b8d4bbf49f2 /crates/mozart/src/commands/install.rs
parenta9b80907286bb74506fc2bfcc22f3d9ce6924472 (diff)
downloadphp-mozart-240b0dd14a607a9dfdb84bb339c87bb0effd6963.tar.gz
php-mozart-240b0dd14a607a9dfdb84bb339c87bb0effd6963.tar.zst
php-mozart-240b0dd14a607a9dfdb84bb339c87bb0effd6963.zip
fix(install): honour branch-alias when checking lock requirements
Mirror Composer's `Locker::getLockedRepository` flow when validating that every root require is satisfied by the lock and when emitting trace operations: a `dev-*` package's `extra.branch-alias` entry surfaces an AliasPackage at the alias version, so requirement matching considers that version too and `MarkAliasInstalled` fires for the branch-alias when the lock has no matching `aliases[]` entry. Dedupe by `alias_normalized` so packages aliased through both sources don't get two trace lines.
Diffstat (limited to 'crates/mozart/src/commands/install.rs')
-rw-r--r--crates/mozart/src/commands/install.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/mozart/src/commands/install.rs b/crates/mozart/src/commands/install.rs
index b41e91a..5c56fbc 100644
--- a/crates/mozart/src/commands/install.rs
+++ b/crates/mozart/src/commands/install.rs
@@ -891,6 +891,16 @@ pub async fn install_from_lock(
// match. Mirrors Composer's `Transaction::calculateOperations` DFS
// which pushes alias targets first and emits MarkAliasInstalled
// when the alias itself is processed.
+ //
+ // Two sources of alias entries: the `aliases[]` block in
+ // `composer.lock` (which the resolver populates with both root
+ // aliases and branch-aliases) and the package's own
+ // `extra.branch-alias` (recovered through
+ // `Locker::getLockedRepository`'s ArrayLoader expansion when the
+ // lock was hand-written without a matching `aliases[]` entry).
+ // The two sources can name the same alias version, so dedupe by
+ // `alias_normalized` to avoid emitting the trace line twice.
+ let mut emitted_alias_versions: Vec<String> = Vec::new();
for alias in &lock.aliases {
if alias.package.eq_ignore_ascii_case(&pkg.name) && alias.version == pkg.version {
executor
@@ -899,8 +909,22 @@ pub async fn install_from_lock(
&exec_ctx,
)
.await?;
+ emitted_alias_versions.push(alias.alias_normalized.clone());
}
}
+ let branch_aliases = lockfile::locked_package_branch_aliases(pkg);
+ for alias in &branch_aliases {
+ if emitted_alias_versions.contains(&alias.alias_normalized) {
+ continue;
+ }
+ executor
+ .install_package(
+ PackageOperation::MarkAliasInstalled { alias, target: pkg },
+ &exec_ctx,
+ )
+ .await?;
+ emitted_alias_versions.push(alias.alias_normalized.clone());
+ }
}
// Step 8: Write updated vendor/composer/installed.json (unless download_only)