From 9bad9ec9d6f3d4f9e46034f638180775466c1286 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Sun, 25 Aug 2024 21:40:42 +0200 Subject: [PATCH] Provide git hash in tooltip --- build.rs | 7 +++++++ src/app/top_bottom.rs | 5 +++-- src/consts.rs | 3 ++- src/main.rs | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build.rs b/build.rs index dd4c340..1ea0adf 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,13 @@ extern crate embed_resource; fn main() -> anyhow::Result<()> { + let output = std::process::Command::new("git") + .args(["rev-parse", "HEAD"]) + .output() + .unwrap(); + let git_hash = String::from_utf8(output.stdout).unwrap(); + println!("cargo:rustc-env=GIT_HASH={}", &git_hash[..7]); + let target = std::env::var("TARGET")?; if target.contains("windows") { embed_resource::compile("static/icon.rc", embed_resource::NONE); diff --git a/src/app/top_bottom.rs b/src/app/top_bottom.rs index 963ff60..4d2fec0 100644 --- a/src/app/top_bottom.rs +++ b/src/app/top_bottom.rs @@ -3,7 +3,7 @@ use std::{path::PathBuf, process::Command}; use egui::{Context, Layout}; use crate::{ - consts::{HOMEPAGE, TOP_SIDE_MARGIN, VERSION}, + consts::{GIT_HASH, HOMEPAGE, TOP_SIDE_MARGIN, VERSION}, toast, }; @@ -122,7 +122,8 @@ impl App { ui.hyperlink_to( format!("{} v {}", egui::special_emojis::GITHUB, VERSION), HOMEPAGE, - ); + ) + .on_hover_text(format!("git revision {GIT_HASH}")); egui::warn_if_debug_build(ui); let old_value = self.sorting; diff --git a/src/consts.rs b/src/consts.rs index 1724a69..a298309 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -1,5 +1,6 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const HOMEPAGE: &str = env!("CARGO_PKG_HOMEPAGE"); -pub const APP_NAME: &str = "File Manager"; +pub const GIT_HASH: &str = env!("GIT_HASH"); +pub const APP_NAME: &str = "LWA File Manager"; pub const VERTICAL_SPACING: f32 = 8.0; pub const TOP_SIDE_MARGIN: f32 = 10.0; diff --git a/src/main.rs b/src/main.rs index 90549c3..a50b4b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] use anyhow::Context; // hide console window on Windows in release -use consts::{APP_NAME, VERSION}; +use consts::APP_NAME; use eframe::egui; mod app; @@ -23,7 +23,7 @@ fn main() -> anyhow::Result<()> { }; eframe::run_native( - &format!("{APP_NAME} v {VERSION}"), + &APP_NAME, native_options, Box::new(|cc| { egui_extras::install_image_loaders(&cc.egui_ctx);