From 81dc9f0e8ff07fe8bdbe5d17d7eae51afe7c5379 Mon Sep 17 00:00:00 2001 From: Nugine Date: Mon, 11 Nov 2024 23:10:48 +0800 Subject: [PATCH] feat(rustfs): adjust short version --- rustfs/src/config/mod.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index 77f72420d..9a22f758b 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -10,8 +10,19 @@ pub const DEFAULT_PORT: u16 = 9000; pub const DEFAULT_ACCESS_KEY: &str = "rustfsadmin"; pub const DEFAULT_SECRET_KEY: &str = "rustfsadmin"; +#[allow(clippy::const_is_empty)] +const SHORT_VERSION: &str = { + if !build::TAG.is_empty() { + build::TAG + } else if !build::SHORT_COMMIT.is_empty() { + concat!("@", build::SHORT_COMMIT) + } else { + build::PKG_VERSION + } +}; + const LONG_VERSION: &str = concat!( - concat!(build::PKG_VERSION, "\n"), + concat!(SHORT_VERSION, "\n"), concat!("build time : ", build::BUILD_TIME, "\n"), concat!("build profile: ", build::BUILD_RUST_CHANNEL, "\n"), concat!("build os : ", build::BUILD_OS, "\n"), @@ -24,7 +35,7 @@ const LONG_VERSION: &str = concat!( ); #[derive(Debug, Parser)] -#[command(version, long_version = LONG_VERSION)] +#[command(version = SHORT_VERSION, long_version = LONG_VERSION)] pub struct Opt { /// DIR points to a directory on a filesystem. #[arg(required = true)]