Allow overriding release channel at runtime via env var

This commit is contained in:
Max Brunsfeld 2022-10-26 15:50:30 -07:00
parent 92a4998ddc
commit f1b41389b3
2 changed files with 5 additions and 4 deletions

View file

@ -991,13 +991,13 @@ impl Client {
.zip(rpc_url.port_or_known_default()) .zip(rpc_url.port_or_known_default())
.ok_or_else(|| anyhow!("missing host in rpc url"))?; .ok_or_else(|| anyhow!("missing host in rpc url"))?;
let stream = smol::net::TcpStream::connect(rpc_host).await?; let stream = smol::net::TcpStream::connect(rpc_host).await?;
rpc_url.set_query(if is_preview { Some("preview=1") } else { None });
log::info!("connected to rpc endpoint {}", rpc_url); log::info!("connected to rpc endpoint {}", rpc_url);
match rpc_url.scheme() { match rpc_url.scheme() {
"https" => { "https" => {
rpc_url.set_scheme("wss").unwrap(); rpc_url.set_scheme("wss").unwrap();
rpc_url.set_query(if is_preview { Some("preview=1") } else { None });
let request = request.uri(rpc_url.as_str()).body(())?; let request = request.uri(rpc_url.as_str()).body(())?;
let (stream, _) = let (stream, _) =
async_tungstenite::async_tls::client_async_tls(request, stream).await?; async_tungstenite::async_tls::client_async_tls(request, stream).await?;

View file

@ -69,14 +69,15 @@ actions!(
); );
const MIN_FONT_SIZE: f32 = 6.0; const MIN_FONT_SIZE: f32 = 6.0;
const RELEASE_CHANNEL_NAME: &str = include_str!("../RELEASE_CHANNEL");
lazy_static! { lazy_static! {
pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME { static ref RELEASE_CHANNEL_NAME: String =
env::var("ZED_RELEASE_CHANNEL").unwrap_or(include_str!("../RELEASE_CHANNEL").to_string());
pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME.as_str() {
"dev" => ReleaseChannel::Dev, "dev" => ReleaseChannel::Dev,
"preview" => ReleaseChannel::Preview, "preview" => ReleaseChannel::Preview,
"stable" => ReleaseChannel::Preview, "stable" => ReleaseChannel::Preview,
_ => panic!("invalid release channel {RELEASE_CHANNEL_NAME}"), _ => panic!("invalid release channel {}", *RELEASE_CHANNEL_NAME),
}; };
} }