diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-03 12:15:02 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-03 12:15:02 +0900 |
| commit | 7badb54195131da9c3561c351138c0ba083e38e4 (patch) | |
| tree | 0498ab8c3bfcf90e01fcecf451a10ad3844514ff /crates/mozart/src/commands/install.rs | |
| parent | dffb6244ebb432477b83631d68584bbc7186dd94 (diff) | |
| download | php-mozart-7badb54195131da9c3561c351138c0ba083e38e4.tar.gz php-mozart-7badb54195131da9c3561c351138c0ba083e38e4.tar.zst php-mozart-7badb54195131da9c3561c351138c0ba083e38e4.zip | |
fix(install): switch update trace to dist-ref mode when source refs match
Composer's UpdateOperation::format renders the from/to versions through
DISPLAY_SOURCE_REF_IF_DEV first, but if both sides come out identical it
re-renders in DISPLAY_SOURCE_REF (when source refs differ) or
DISPLAY_DIST_REF (when only dist refs differ) so the trace doesn't show
a useless `pkg (X => X)` line. Mozart skipped the switch and emitted the
default form on both halves, so a same-version-different-dist-ref update
showed up as `dev-master def000 => dev-master def000` instead of
`dev-master def000 => dev-master`.
Add format_update_pretty_versions to render the pair Composer's way and
plumb the resolved to_full_pretty through PackageOperation::Update so
the trace recorder uses it verbatim.
Unblocks update_installed_reference and update_picks_up_change_of_vcs_type
installer fixtures.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands/install.rs')
| -rw-r--r-- | crates/mozart/src/commands/install.rs | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/crates/mozart/src/commands/install.rs b/crates/mozart/src/commands/install.rs index f809a86..7aac3af 100644 --- a/crates/mozart/src/commands/install.rs +++ b/crates/mozart/src/commands/install.rs @@ -5,7 +5,7 @@ use mozart_core::console_format; use mozart_registry::installed; use mozart_registry::installer_executor::{ ExecuteContext, FilesystemExecutor, InstallerExecutor, PackageOperation, - format_full_pretty_version_for_installed, + format_full_pretty_version, format_update_pretty_versions, }; use mozart_registry::lockfile; use std::collections::BTreeMap; @@ -675,10 +675,11 @@ pub async fn install_from_lock( } for (pkg, action) in &ops { - // Owned scratch buffer the Update branch borrows for - // `PackageOperation::Update::from_version`. Declared at loop - // scope so the borrow outlives the await call. - let from_version_buf; + // Owned scratch buffers the Update branch borrows for + // `PackageOperation::Update::{from_full_pretty,to_full_pretty}`. + // Declared at loop scope so the borrows outlive the await call. + let from_full_pretty_buf; + let to_full_pretty_buf; let op = match action { Action::Skip => continue, Action::Install => { @@ -695,24 +696,32 @@ pub async fn install_from_lock( pkg.name, pkg.version )); - // Pull the previously-installed version from installed.json + // Pull the previously-installed entry from installed.json // so the trace recorder can format // `Upgrading pkg (oldVersion => newVersion)`. The plain // version drives the upgrade/downgrade direction; the - // full-pretty form (with the dev reference suffix) is - // what shows up in the trace, mirroring Composer's - // `UpdateOperation::format`. + // full-pretty pair is rendered through + // `format_update_pretty_versions` so Composer's + // SOURCE_REF / DIST_REF mode switch (used when both + // sides would otherwise render identically) lands on + // both halves. let from_entry = installed .packages .iter() .find(|p| p.name.eq_ignore_ascii_case(&pkg.name)); let from_version = from_entry.map(|p| p.version.as_str()).unwrap_or(""); - from_version_buf = from_entry - .map(format_full_pretty_version_for_installed) - .unwrap_or_default(); + if let Some(entry) = from_entry { + let (from, to) = format_update_pretty_versions(entry, pkg); + from_full_pretty_buf = from; + to_full_pretty_buf = to; + } else { + from_full_pretty_buf = String::new(); + to_full_pretty_buf = format_full_pretty_version(pkg); + } PackageOperation::Update { from_version, - from_full_pretty: &from_version_buf, + from_full_pretty: &from_full_pretty_buf, + to_full_pretty: &to_full_pretty_buf, package: pkg, } } |
