Make the commit sha availabe in the app, via a global

Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Kirill <kirill@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-11-17 14:52:43 -08:00
parent a8bea41ad8
commit a03d062120
4 changed files with 29 additions and 7 deletions

View file

@ -23,7 +23,7 @@ use std::{borrow::Cow, ops::Deref, sync::Arc};
use terminal_view::terminal_panel::TerminalPanel;
use util::{
asset_str,
channel::ReleaseChannel,
channel::{AppCommitSha, ReleaseChannel},
paths::{self, LOCAL_SETTINGS_RELATIVE_PATH},
ResultExt,
};
@ -432,9 +432,16 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
}
fn about(_: &mut Workspace, _: &About, cx: &mut gpui::ViewContext<Workspace>) {
use std::fmt::Write as _;
let app_name = cx.global::<ReleaseChannel>().display_name();
let version = env!("CARGO_PKG_VERSION");
let prompt = cx.prompt(PromptLevel::Info, &format!("{app_name} {version}"), &["OK"]);
let mut message = format!("{app_name} {version}");
if let Some(sha) = cx.try_global::<AppCommitSha>() {
write!(&mut message, "\n\n{}", sha.0).unwrap();
}
let prompt = cx.prompt(PromptLevel::Info, &message, &["OK"]);
cx.foreground_executor()
.spawn(async {
prompt.await.ok();