chore: add git hash to info command

This commit is contained in:
tretrauit 2024-01-12 18:15:30 +07:00
parent 50c4b69eb5
commit 8c581348c1
2 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,15 @@
use std::process::Command;
// Example custom build script. // Example custom build script.
fn main() { fn main() {
// Get the git commit hash (short)
let output = Command::new("git")
.args(&["rev-parse", "--short", "HEAD"])
.output()
.expect("Failed to execute git command");
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
println!( println!(
"cargo:rustc-env=BUILD_PROFILE={}", "cargo:rustc-env=BUILD_PROFILE={}",
std::env::var("PROFILE").unwrap() std::env::var("PROFILE").unwrap()

View File

@ -368,11 +368,12 @@ async fn debug(ctx: &Context, msg: &Message) -> CommandResult {
#[command] #[command]
async fn info(ctx: &Context, msg: &Message) -> CommandResult { async fn info(ctx: &Context, msg: &Message) -> CommandResult {
let reply_str = format!( let reply_str = format!(
"Swordfish v{} - {}\n\ "Swordfish v{} ({}) - {}\n\
Log level: `{}`\n\ Log level: `{}`\n\
Build type: `{}`\n\n\ Build type: `{}`\n\n\
Like my work? Consider supporting me at my [Ko-fi](https://ko-fi.com/tretrauit) or [Patreon](https://patreon.com/tretrauit)!", Like my work? Consider supporting me at my [Ko-fi](https://ko-fi.com/tretrauit) or [Patreon](https://patreon.com/tretrauit)!",
env!("CARGO_PKG_VERSION"), env!("CARGO_PKG_VERSION"),
env!("GIT_HASH"),
GITHUB_URL, GITHUB_URL,
CONFIG.get().unwrap().log.level.clone().as_str(), CONFIG.get().unwrap().log.level.clone().as_str(),
env!("BUILD_PROFILE"), env!("BUILD_PROFILE"),