Store current release channel name in a file in the zed crate

This commit is contained in:
Max Brunsfeld 2022-10-26 10:32:30 -07:00
parent 1cdd3c0e28
commit a4a8596a29
10 changed files with 80 additions and 36 deletions

View file

@ -9,11 +9,11 @@ use anyhow::{anyhow, Context, Result};
use assets::Assets;
use breadcrumbs::Breadcrumbs;
pub use client;
use client::PREVIEW_CHANNEL;
use collab_ui::{CollabTitlebarItem, ToggleCollaborationMenu};
use collections::VecDeque;
pub use editor;
use editor::{Editor, MultiBuffer};
use lazy_static::lazy_static;
use gpui::{
actions,
@ -29,7 +29,7 @@ use project_panel::ProjectPanel;
use search::{BufferSearchBar, ProjectSearchBar};
use serde::Deserialize;
use serde_json::to_string_pretty;
use settings::{keymap_file_json_schema, settings_file_json_schema, Settings};
use settings::{keymap_file_json_schema, settings_file_json_schema, ReleaseChannel, Settings};
use std::{env, path::Path, str, sync::Arc};
use util::ResultExt;
pub use workspace;
@ -69,6 +69,16 @@ actions!(
);
const MIN_FONT_SIZE: f32 = 6.0;
const RELEASE_CHANNEL_NAME: &str = include_str!("../RELEASE_CHANNEL");
lazy_static! {
pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME {
"dev" => ReleaseChannel::Dev,
"preview" => ReleaseChannel::Preview,
"stable" => ReleaseChannel::Preview,
_ => panic!("invalid release channel {RELEASE_CHANNEL_NAME}"),
};
}
pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
cx.add_action(about);
@ -378,11 +388,15 @@ fn quit(_: &Quit, cx: &mut gpui::MutableAppContext) {
}
fn about(_: &mut Workspace, _: &About, cx: &mut gpui::ViewContext<Workspace>) {
let channel = if *PREVIEW_CHANNEL { "Preview " } else { "" };
let app_name = match *cx.global::<ReleaseChannel>() {
ReleaseChannel::Dev => "Zed Dev",
ReleaseChannel::Preview => "Zed Preview",
ReleaseChannel::Stable => "Zed",
};
let version = env!("CARGO_PKG_VERSION");
cx.prompt(
gpui::PromptLevel::Info,
&format!("Zed {channel}{version}"),
&format!("{app_name} {version}"),
&["OK"],
);
}