aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-registry/src/installer_executor/mod.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-03 12:32:10 +0900
committernsfisis <nsfisis@gmail.com>2026-05-03 12:32:10 +0900
commit2af684c6397001944c9d9aac20ca59677d6a9650 (patch)
tree054f40875ca547223c36f19e876269baadb1bf6f /crates/mozart-registry/src/installer_executor/mod.rs
parentab2772b8c85139df7d5e625ac5262d385e5ab4c0 (diff)
downloadphp-mozart-2af684c6397001944c9d9aac20ca59677d6a9650.tar.gz
php-mozart-2af684c6397001944c9d9aac20ca59677d6a9650.tar.zst
php-mozart-2af684c6397001944c9d9aac20ca59677d6a9650.zip
fix(install): emit MarkAliasUninstalled and fix dev-branch upgrade direction
Two pieces of Composer's update-trace machinery were missing: 1. VersionParser::isUpgrade in Composer\Package\Version (which overrides the upstream Semver one) substitutes dev-master / dev-trunk / dev-default with the 9999999-dev default-branch alias, then returns true whenever either side starts with `dev-`. Mozart's is_upgrade compared via the generic version order, so dev-master → dev-foo came out as Downgrading. Port the override. 2. Transaction::calculateOperations seeds removeAliasMap from the currently-installed AliasPackages and emits MarkAliasUninstalled for every entry not covered by the new lock. Mozart never emitted those, so updating away from a branch-aliased package produced no trace line for the alias retirement. Walk installed.json's `extra.branch-alias` map, compare against the new lock's aliases[] block, and emit a MarkAliasUninstalled PackageOperation (a new variant on the executor surface — no filesystem effects, only the trace recorder cares). Unblocks update_alias, update_alias_lock2, and update_no_dev_still_resolves_dev installer fixtures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-registry/src/installer_executor/mod.rs')
-rw-r--r--crates/mozart-registry/src/installer_executor/mod.rs43
1 files changed, 36 insertions, 7 deletions
diff --git a/crates/mozart-registry/src/installer_executor/mod.rs b/crates/mozart-registry/src/installer_executor/mod.rs
index a774490..c344ba4 100644
--- a/crates/mozart-registry/src/installer_executor/mod.rs
+++ b/crates/mozart-registry/src/installer_executor/mod.rs
@@ -54,6 +54,23 @@ pub enum PackageOperation<'a> {
/// reference suffix for the trace line.
target: &'a LockedPackage,
},
+ /// Mark a previously-installed alias as uninstalled. No filesystem
+ /// effects — only the trace recorder cares. Mirrors Composer's
+ /// `MarkAliasUninstalledOperation`. Composer derives the AliasPackage
+ /// from the previous installed.json entries (via `extra.branch-alias`),
+ /// then emits this when the alias is no longer in the result. Caller
+ /// pre-renders the display strings so this variant doesn't need to know
+ /// how to spelunk the entry.
+ MarkAliasUninstalled {
+ /// Package name (e.g. `a/a`) used as both the alias's name and the
+ /// target's name on the trace line.
+ name: &'a str,
+ /// Alias's full-pretty form (alias pretty version plus reference
+ /// suffix), e.g. `1.0.x-dev master`.
+ alias_full: &'a str,
+ /// Target's full-pretty form, e.g. `dev-master master`.
+ target_full: &'a str,
+ },
}
impl<'a> PackageOperation<'a> {
@@ -62,7 +79,8 @@ impl<'a> PackageOperation<'a> {
PackageOperation::Install { package } | PackageOperation::Update { package, .. } => {
Some(package)
}
- PackageOperation::MarkAliasInstalled { .. } => None,
+ PackageOperation::MarkAliasInstalled { .. }
+ | PackageOperation::MarkAliasUninstalled { .. } => None,
}
}
}
@@ -92,11 +110,14 @@ pub fn format_full_pretty_with_pretty(pretty_version: &str, pkg: &LockedPackage)
)
}
-/// Mirror Composer's `BasePackage::getFullPrettyVersion()` for an
-/// `InstalledPackageEntry`. Same display rules as
-/// [`format_full_pretty_version`] but pulls source/dist info out of the
-/// installed.json `source`/`dist` JSON values.
-pub fn format_full_pretty_version_for_installed(entry: &InstalledPackageEntry) -> String {
+/// Same as [`format_full_pretty_version_for_installed`] but lets the caller
+/// supply an alternate pretty version. Used when emitting
+/// `MarkAliasUninstalled`: the alias's `1.0.x-dev` text needs to be rendered
+/// with the *target installed entry's* reference suffix.
+pub fn format_full_pretty_with_pretty_for_installed(
+ pretty_version: &str,
+ entry: &InstalledPackageEntry,
+) -> String {
let source_ref = entry
.source
.as_ref()
@@ -113,7 +134,7 @@ pub fn format_full_pretty_version_for_installed(entry: &InstalledPackageEntry) -
.and_then(|v| v.get("type"))
.and_then(|v| v.as_str());
format_full_pretty_with_refs(
- &entry.version,
+ pretty_version,
&entry.version,
source_ref,
dist_ref,
@@ -121,6 +142,14 @@ pub fn format_full_pretty_version_for_installed(entry: &InstalledPackageEntry) -
)
}
+/// Mirror Composer's `BasePackage::getFullPrettyVersion()` for an
+/// `InstalledPackageEntry`. Same display rules as
+/// [`format_full_pretty_version`] but pulls source/dist info out of the
+/// installed.json `source`/`dist` JSON values.
+pub fn format_full_pretty_version_for_installed(entry: &InstalledPackageEntry) -> String {
+ format_full_pretty_with_pretty_for_installed(&entry.version, entry)
+}
+
/// Render the from/to display strings for an update trace line, mirroring
/// Composer's `UpdateOperation::format`. Defaults to `DISPLAY_SOURCE_REF_IF_DEV`,
/// then if both sides render identically: