Skip to content

Commit

Permalink
Provide git hash in tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Leinnan committed Aug 25, 2024
1 parent b60fd33 commit 9bad9ec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
7 changes: 7 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/app/top_bottom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion src/consts.rs
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 9bad9ec

Please sign in to comment.