mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(upgrade): correctly compute latest version based on current release channel (#25087)
This commit fixes computation of the latest available version by taking into account which release channel the current binary is on. Before this commit, if user was on "RC" channel, calling `deno upgrade` would not switch back to the "stable" channel.
This commit is contained in:
parent
2e9d3b688c
commit
f003d6498c
1 changed files with 33 additions and 11 deletions
|
@ -543,6 +543,7 @@ pub async fn upgrade(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum RequestedVersion {
|
||||
Latest(ReleaseChannel),
|
||||
SpecificVersion(ReleaseChannel, String),
|
||||
|
@ -662,19 +663,19 @@ async fn find_latest_version_to_upgrade(
|
|||
.await?;
|
||||
|
||||
let (maybe_newer_latest_version, current_version) = match release_channel {
|
||||
ReleaseChannel::Stable | ReleaseChannel::Rc => {
|
||||
ReleaseChannel::Stable => {
|
||||
let current_version = version::DENO_VERSION_INFO.deno;
|
||||
let current_is_most_recent = if version::DENO_VERSION_INFO.release_channel
|
||||
!= ReleaseChannel::Canary
|
||||
{
|
||||
|
||||
// If the current binary is not a stable channel, we can skip
|
||||
// computation if we're on a newer release - we're not.
|
||||
if version::DENO_VERSION_INFO.release_channel != ReleaseChannel::Stable {
|
||||
(Some(latest_version_found), current_version)
|
||||
} else {
|
||||
let current = Version::parse_standard(current_version).unwrap();
|
||||
let latest =
|
||||
Version::parse_standard(&latest_version_found.version_or_hash)
|
||||
.unwrap();
|
||||
current >= latest
|
||||
} else {
|
||||
false
|
||||
};
|
||||
let current_is_most_recent = current >= latest;
|
||||
|
||||
if !force && current_is_most_recent {
|
||||
(None, current_version)
|
||||
|
@ -682,6 +683,27 @@ async fn find_latest_version_to_upgrade(
|
|||
(Some(latest_version_found), current_version)
|
||||
}
|
||||
}
|
||||
}
|
||||
ReleaseChannel::Rc => {
|
||||
let current_version = version::DENO_VERSION_INFO.deno;
|
||||
|
||||
// If the current binary is not an rc channel, we can skip
|
||||
// computation if we're on a newer release - we're not.
|
||||
if version::DENO_VERSION_INFO.release_channel != ReleaseChannel::Rc {
|
||||
(Some(latest_version_found), current_version)
|
||||
} else {
|
||||
let current = Version::parse_standard(current_version).unwrap();
|
||||
let latest =
|
||||
Version::parse_standard(&latest_version_found.version_or_hash)
|
||||
.unwrap();
|
||||
let current_is_most_recent = current >= latest;
|
||||
if !force && current_is_most_recent {
|
||||
(None, current_version)
|
||||
} else {
|
||||
(Some(latest_version_found), current_version)
|
||||
}
|
||||
}
|
||||
}
|
||||
ReleaseChannel::Canary => {
|
||||
let current_version = version::DENO_VERSION_INFO.git_hash;
|
||||
let current_is_most_recent =
|
||||
|
|
Loading…
Reference in a new issue