Detailed changes
@@ -1,6 +1,5 @@
-use std::env;
-
use lazy_static::lazy_static;
+use std::env;
lazy_static! {
pub static ref RELEASE_CHANNEL_NAME: String = if cfg!(debug_assertions) {
@@ -18,6 +17,8 @@ lazy_static! {
};
}
+pub struct AppCommitSha(pub String);
+
#[derive(Copy, Clone, PartialEq, Eq, Default)]
pub enum ReleaseChannel {
#[default]
@@ -40,7 +41,6 @@ impl ReleaseChannel {
pub fn dev_name(&self) -> &'static str {
match self {
ReleaseChannel::Dev => "dev",
- // TODO kb need to add DB data
ReleaseChannel::Nightly => "nightly",
ReleaseChannel::Preview => "preview",
ReleaseChannel::Stable => "stable",
@@ -69,7 +69,6 @@ impl ReleaseChannel {
pub fn release_query_param(&self) -> Option<&'static str> {
match self {
Self::Dev => None,
- // TODO kb need to add server handling
Self::Nightly => Some("nightly=1"),
Self::Preview => Some("preview=1"),
Self::Stable => None,
@@ -1,3 +1,5 @@
+use std::process::Command;
+
fn main() {
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.15.7");
@@ -21,4 +23,14 @@ fn main() {
// Register exported Objective-C selectors, protocols, etc
println!("cargo:rustc-link-arg=-Wl,-ObjC");
+
+ // Populate git sha environment variable if git is available
+ if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() {
+ if output.status.success() {
+ println!(
+ "cargo:rustc-env=ZED_COMMIT_SHA={}",
+ String::from_utf8_lossy(&output.stdout).trim()
+ );
+ }
+ }
}
@@ -43,7 +43,7 @@ use std::{
use theme::ActiveTheme;
use util::{
async_maybe,
- channel::{parse_zed_link, ReleaseChannel, RELEASE_CHANNEL},
+ channel::{parse_zed_link, AppCommitSha, ReleaseChannel, RELEASE_CHANNEL},
http::{self, HttpClient},
paths, ResultExt,
};
@@ -113,6 +113,10 @@ fn main() {
app.run(move |cx| {
cx.set_global(*RELEASE_CHANNEL);
+ if let Some(build_sha) = option_env!("ZED_COMMIT_SHA") {
+ cx.set_global(AppCommitSha(build_sha.into()))
+ }
+
cx.set_global(listener.clone());
load_embedded_fonts(cx);
@@ -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();