diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bc271ad --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +crates/client/commit.txt export-subst diff --git a/crates/client/build.rs b/crates/client/build.rs index 5a2a245..5e7a9f1 100644 --- a/crates/client/build.rs +++ b/crates/client/build.rs @@ -387,4 +387,24 @@ fn target() { _ => format!("{arch}-{os}"), }; println!("cargo::rustc-env=YUMUSH_TARGET={target}"); + commit(); +} + +fn commit() { + println!("cargo::rerun-if-changed=commit.txt"); + println!("cargo::rerun-if-changed=../../.git/HEAD"); + println!("cargo::rerun-if-changed=../../.git/refs/heads"); + let stamped = fs::read_to_string("commit.txt").unwrap_or_default(); + let commit = if stamped.starts_with("$Format") { + std::process::Command::new("git") + .args(["log", "-1", "--format=%h %cs"]) + .output() + .ok() + .filter(|out| out.status.success()) + .map(|out| String::from_utf8_lossy(&out.stdout).into_owned()) + .unwrap_or_else(|| "dev".to_string()) + } else { + stamped + }; + println!("cargo::rustc-env=YUMUSH_COMMIT={}", commit.trim()); } diff --git a/crates/client/commit.txt b/crates/client/commit.txt new file mode 100644 index 0000000..6586a96 --- /dev/null +++ b/crates/client/commit.txt @@ -0,0 +1 @@ +$Format:%h %cs$ diff --git a/crates/client/lang/en/settings_page.txt b/crates/client/lang/en/settings_page.txt index 01fb7ee..2e1251e 100644 --- a/crates/client/lang/en/settings_page.txt +++ b/crates/client/lang/en/settings_page.txt @@ -29,3 +29,7 @@ codec = Codec share_audio = Share audio back_esc = Back (esc) clock_seconds = Show seconds +about = About +version = Version +commit = Commit +target = Target diff --git a/crates/client/lang/tr/settings_page.txt b/crates/client/lang/tr/settings_page.txt index 2ce7538..e15af47 100644 --- a/crates/client/lang/tr/settings_page.txt +++ b/crates/client/lang/tr/settings_page.txt @@ -29,3 +29,7 @@ codec = Kodek share_audio = Sesi paylaş back_esc = Geri (esc) clock_seconds = Saniyeleri göster +about = Hakkında +version = Sürüm +commit = Commit +target = Hedef diff --git a/crates/client/src/gui/settings_page.rs b/crates/client/src/gui/settings_page.rs index 9e500c1..f929518 100644 --- a/crates/client/src/gui/settings_page.rs +++ b/crates/client/src/gui/settings_page.rs @@ -35,15 +35,17 @@ pub(super) enum SettingsSection { Voice, CameraShare, Appearance, + About, DangerZone, } impl SettingsSection { - pub(super) const ALL: [Self; 5] = [ + pub(super) const ALL: [Self; 6] = [ Self::Profile, Self::Voice, Self::CameraShare, Self::Appearance, + Self::About, Self::DangerZone, ]; @@ -53,6 +55,7 @@ impl SettingsSection { Self::Voice => "voice", Self::CameraShare => "camera_share", Self::Appearance => "appearance", + Self::About => "about", Self::DangerZone => "danger_zone", } } @@ -64,12 +67,13 @@ impl SettingsSection { Self::Voice => w.voice, Self::CameraShare => w.camera_share, Self::Appearance => w.appearance, + Self::About => w.about, Self::DangerZone => w.danger_zone, } } } -pub(super) fn setting_rows() -> [(SettingsSection, &'static str); 25] { +pub(super) fn setting_rows() -> [(SettingsSection, &'static str); 28] { let s = &w().settings_page; let v = &w().voice_settings; [ @@ -98,6 +102,9 @@ pub(super) fn setting_rows() -> [(SettingsSection, &'static str); 25] { (SettingsSection::Appearance, s.launch), (SettingsSection::Appearance, s.clock_seconds), (SettingsSection::Appearance, s.your_hue), + (SettingsSection::About, s.version), + (SettingsSection::About, s.commit), + (SettingsSection::About, s.target), ] } @@ -278,6 +285,19 @@ impl Yumush { palette, appearance, )); + sections.push(section( + SettingsSection::About.id(), + SettingsSection::About.label(), + palette, + [ + (w().settings_page.version, crate::VERSION), + (w().settings_page.commit, crate::COMMIT), + (w().settings_page.target, crate::TARGET), + ] + .into_iter() + .map(|(label, value)| row(label, div().text_color(palette.muted).child(value))) + .collect(), + )); if self.user.is_some() { sections.push(danger( SettingsSection::DangerZone.id(), diff --git a/crates/client/src/lib.rs b/crates/client/src/lib.rs index 91323ac..fca2a3d 100644 --- a/crates/client/src/lib.rs +++ b/crates/client/src/lib.rs @@ -24,6 +24,9 @@ pub use usage; pub mod voice; pub const NAME: &str = "Yumush"; +pub const VERSION: &str = env!("CARGO_PKG_VERSION"); +pub const COMMIT: &str = env!("YUMUSH_COMMIT"); +pub const TARGET: &str = env!("YUMUSH_TARGET"); static EXE: std::sync::LazyLock> = std::sync::LazyLock::new(|| std::env::current_exe().ok()); diff --git a/crates/client/src/main.rs b/crates/client/src/main.rs index 8c2692d..8cafd16 100644 --- a/crates/client/src/main.rs +++ b/crates/client/src/main.rs @@ -18,6 +18,15 @@ use tracing::Level; use tracing_subscriber::{filter::Targets, layer::SubscriberExt, util::SubscriberInitExt}; fn main() { + if std::env::args().any(|arg| arg == "--version" || arg == "-V") { + println!( + "yumush {} {} {}", + client::VERSION, + client::COMMIT, + client::TARGET + ); + return; + } tracing_subscriber::registry() .with(tracing_subscriber::fmt::layer()) .with(