From a5ba198b9aa189da58b015a6e4585aaf33208a46 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Thu, 16 Jan 2025 12:03:25 -0800 Subject: [PATCH] fix(outdated): Use `latest` tag even when it's the same as the current version (#27699) Fixes https://github.com/denoland/deno/issues/27696. Just a `>` that should've been a `>=`. Also made sure to filter out deprecated versions. --- cli/tools/registry/pm/deps.rs | 15 +++++++++++++-- .../update/latest_not_pre_release/__test__.jsonc | 13 +++++++++++++ .../update/latest_not_pre_release/package.json | 5 +++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tests/specs/update/latest_not_pre_release/__test__.jsonc create mode 100644 tests/specs/update/latest_not_pre_release/package.json diff --git a/cli/tools/registry/pm/deps.rs b/cli/tools/registry/pm/deps.rs index 3d152490e8..621dd4693d 100644 --- a/cli/tools/registry/pm/deps.rs +++ b/cli/tools/registry/pm/deps.rs @@ -683,10 +683,21 @@ impl DepManager { .and_then(|info| { let latest_tag = info.dist_tags.get("latest")?; let lower_bound = &semver_compatible.as_ref()?.version; - if latest_tag > lower_bound { + if latest_tag >= lower_bound { Some(latest_tag.clone()) } else { - latest_version(Some(latest_tag), info.versions.keys()) + latest_version( + Some(latest_tag), + info.versions.iter().filter_map( + |(version, version_info)| { + if version_info.deprecated.is_none() { + Some(version) + } else { + None + } + }, + ), + ) } }) .map(|version| PackageNv { diff --git a/tests/specs/update/latest_not_pre_release/__test__.jsonc b/tests/specs/update/latest_not_pre_release/__test__.jsonc new file mode 100644 index 0000000000..2bfb7a3aa5 --- /dev/null +++ b/tests/specs/update/latest_not_pre_release/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "install", + "output": "[WILDCARD]" + }, + { + "args": "outdated", + "output": "" + } + ] +} diff --git a/tests/specs/update/latest_not_pre_release/package.json b/tests/specs/update/latest_not_pre_release/package.json new file mode 100644 index 0000000000..581e10cce7 --- /dev/null +++ b/tests/specs/update/latest_not_pre_release/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@denotest/has-pre-release": "1.0.0" + } +}