Skip to content

Commit

Permalink
About: include git tag in about message
Browse files Browse the repository at this point in the history
  • Loading branch information
mdgaziur committed Jun 5, 2024
1 parent a1f1bee commit d81b023
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions crates/findex/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::process::Command;

fn main() {
let git_commit = match Command::new("git")
.args(&["describe", "--tags"])
.output() {
Ok(output) => {
if output.status.success() {
String::from_utf8_lossy(&output.stdout).to_string()
} else {
String::from("[git was unavailable in build time]")
}
},
Err(_) => String::from("[git was unavailable in build time]"),
};

println!("cargo:rustc-env=GIT_COMMIT={git_commit}");
}
2 changes: 1 addition & 1 deletion crates/findex/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static FINDEX_VERSION: &str = env!("CARGO_PKG_VERSION");

fn main() {
if std::env::args().any(|arg| arg == "--about") {
println!("Findex v{FINDEX_VERSION}");
println!("Findex v{FINDEX_VERSION} from {}", env!("GIT_COMMIT"));
println!("Author: MD Gaziur Rahman Noor <mdgaziurrahmannoor@gmail.com>");
println!("License: GPL3");
println!("Report issues at: https://github.com/mdgaziur/findex/issues");
Expand Down

0 comments on commit d81b023

Please sign in to comment.