-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prompt user to install the override toolchain if its specified but not installed yet #656
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
use crate::{ | ||
constants::{ | ||
CHANNEL_BETA_1_FILE_NAME, CHANNEL_BETA_2_FILE_NAME, CHANNEL_BETA_3_FILE_NAME, | ||
CHANNEL_BETA_4_FILE_NAME, CHANNEL_BETA_5_FILE_NAME, CHANNEL_DEVNET_FILE_NAME, | ||
CHANNEL_LATEST_FILE_NAME, CHANNEL_NIGHTLY_FILE_NAME, CHANNEL_TESTNET_FILE_NAME, | ||
DATE_FORMAT_URL_FRIENDLY, FUELUP_GH_PAGES, | ||
BETA_CHANNELS, CHANNEL_BETA_1_FILE_NAME, CHANNEL_BETA_2_FILE_NAME, | ||
CHANNEL_BETA_3_FILE_NAME, CHANNEL_BETA_4_FILE_NAME, CHANNEL_BETA_5_FILE_NAME, | ||
CHANNEL_DEVNET_FILE_NAME, CHANNEL_LATEST_FILE_NAME, CHANNEL_NIGHTLY_FILE_NAME, | ||
CHANNEL_TESTNET_FILE_NAME, DATE_FORMAT_URL_FRIENDLY, GITHUB_USER_CONTENT_URL, | ||
}, | ||
download::{download, DownloadCfg}, | ||
toolchain::{DistToolchainDescription, DistToolchainName}, | ||
|
@@ -17,21 +17,6 @@ use time::Date; | |
use toml_edit::de; | ||
use tracing::warn; | ||
|
||
pub const LATEST: &str = "latest"; | ||
pub const STABLE: &str = "stable"; | ||
pub const BETA_1: &str = "beta-1"; | ||
pub const BETA_2: &str = "beta-2"; | ||
pub const BETA_3: &str = "beta-3"; | ||
pub const BETA_4: &str = "beta-4"; | ||
pub const BETA_5: &str = "beta-5"; | ||
pub const DEVNET: &str = "devnet"; | ||
pub const TESTNET: &str = "testnet"; | ||
pub const NIGHTLY: &str = "nightly"; | ||
|
||
pub const CHANNELS: [&str; 9] = [ | ||
LATEST, NIGHTLY, BETA_1, BETA_2, BETA_3, BETA_4, BETA_5, DEVNET, TESTNET, | ||
]; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct HashedBinary { | ||
pub url: String, | ||
|
@@ -50,14 +35,11 @@ pub struct Package { | |
pub fuels_version: Option<String>, | ||
} | ||
|
||
pub fn is_beta_toolchain(name: &str) -> bool { | ||
name == BETA_1 | ||
|| name == BETA_2 | ||
|| name == BETA_3 | ||
|| name == BETA_4 | ||
|| name == BETA_5 | ||
|| name == DEVNET | ||
|| name == TESTNET | ||
pub fn is_beta_toolchain(name: &str) -> Option<&str> { | ||
BETA_CHANNELS | ||
.iter() | ||
.find(|&beta_channel| name.starts_with(beta_channel)) | ||
.copied() | ||
} | ||
|
||
fn format_nightly_url(date: &Date) -> Result<String> { | ||
|
@@ -68,7 +50,7 @@ fn format_nightly_url(date: &Date) -> Result<String> { | |
} | ||
|
||
fn construct_channel_url(desc: &DistToolchainDescription) -> Result<String> { | ||
let mut url = FUELUP_GH_PAGES.to_owned(); | ||
let mut url = format!("{}{}/gh-pages/", GITHUB_USER_CONTENT_URL, "fuelup"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer to keep
|
||
match desc.name { | ||
DistToolchainName::Latest => { | ||
if let Some(date) = desc.date { | ||
|
@@ -136,7 +118,7 @@ If this component should be downloadable, try running `fuelup self update` and r | |
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::{download::DownloadCfg, file::read_file}; | ||
use crate::{constants::CHANNELS, download::DownloadCfg, file::read_file}; | ||
|
||
#[test] | ||
fn channel_from_toml() { | ||
|
@@ -246,4 +228,14 @@ mod tests { | |
assert_eq!(cfgs[1].name, "fuel-core"); | ||
assert_eq!(cfgs[1].version, Version::parse("0.9.4").unwrap()); | ||
} | ||
|
||
#[test] | ||
fn test_all_channels_for_beta() { | ||
for channel in CHANNELS.iter() { | ||
assert_eq!( | ||
is_beta_toolchain(channel).is_some(), | ||
BETA_CHANNELS.contains(channel) | ||
); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
use crate::constants::CHANNELS; | ||
use crate::ops::fuelup_toolchain::{install::install, new::new, uninstall::uninstall}; | ||
use crate::target_triple::TargetTriple; | ||
use crate::toolchain::RESERVED_TOOLCHAIN_NAMES; | ||
use anyhow::{bail, Result}; | ||
use clap::Parser; | ||
|
||
|
@@ -45,7 +45,7 @@ fn name_allowed(s: &str) -> Result<String> { | |
None => s, | ||
}; | ||
|
||
if RESERVED_TOOLCHAIN_NAMES.contains(&name) { | ||
if CHANNELS.contains(&name) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
bail!( | ||
"Cannot use distributable toolchain name '{}' as a custom toolchain name", | ||
s | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
use crate::constants::CHANNELS; | ||
use crate::fmt::format_toolchain_with_target; | ||
use crate::path::toolchains_dir; | ||
use crate::toolchain::RESERVED_TOOLCHAIN_NAMES; | ||
use anyhow::Result; | ||
use std::{fs, io, path::PathBuf}; | ||
|
||
|
@@ -25,7 +25,7 @@ impl Config { | |
.filter(|e| e.file_type().map(|f| f.is_dir()).unwrap_or(false)) | ||
{ | ||
let toolchain = dir_entry.file_name().to_string_lossy().to_string(); | ||
if RESERVED_TOOLCHAIN_NAMES | ||
if CHANNELS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here. |
||
.iter() | ||
.any(|t| toolchain == format_toolchain_with_target(t)) | ||
{ | ||
|
@@ -54,7 +54,7 @@ impl Config { | |
.map(|e| e.file_name().into_string().ok().unwrap_or_default()) | ||
.collect(); | ||
|
||
for name in RESERVED_TOOLCHAIN_NAMES { | ||
for name in CHANNELS { | ||
let dist_toolchain = format_toolchain_with_target(name); | ||
if installed_toolchains.contains(&dist_toolchain) { | ||
dist_toolchains.push(name.to_string()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still be
name == beta_channel
?