From 86c8921fdd59bf2ca0070242a9979142a807ce4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sun, 22 Oct 2023 21:18:00 +0200 Subject: [PATCH] fix(cli): proper version in vault info --- cli/src/common.rs | 4 ++++ cli/src/main.rs | 2 +- cli/src/routes.rs | 13 ++----------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/cli/src/common.rs b/cli/src/common.rs index eaa41c2..c6f4994 100644 --- a/cli/src/common.rs +++ b/cli/src/common.rs @@ -36,3 +36,7 @@ lazy_static! { .build() .unwrap(); } + +pub fn get_version() -> &'static str { + option_env!("UPEND_VERSION").unwrap_or("unknown") +} \ No newline at end of file diff --git a/cli/src/main.rs b/cli/src/main.rs index 7fb6cc2..6b9e3a0 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -179,7 +179,7 @@ struct ServeArgs { #[actix_web::main] async fn main() -> Result<()> { - let command = Cli::command().version(option_env!("UPEND_VERSION").unwrap_or("unknown")); + let command = Cli::command().version(crate::common::get_version()); let args = Cli::from_arg_matches(&command.get_matches())?; tracing_subscriber::fmt() diff --git a/cli/src/routes.rs b/cli/src/routes.rs index fc705f4..20a4c51 100644 --- a/cli/src/routes.rs +++ b/cli/src/routes.rs @@ -832,7 +832,8 @@ pub async fn get_info(state: web::Data) -> Result { "name": state.config.vault_name, // "location": &*state.store.path, "version": format!( - "{} / {} / {}", + "{} (base: {}, db: {}, cli: {})", + crate::common::get_version(), upend_base::common::build::PKG_VERSION, upend_db::common::build::PKG_VERSION, build::PKG_VERSION @@ -970,21 +971,11 @@ mod tests { #[derive(Deserialize)] struct VaultInfo { name: Option, - version: String, desktop: bool, } let info: VaultInfo = actix_web::test::call_and_read_body_json(&app, req).await; assert_eq!(info.name, Some("TEST VAULT".to_string())); - assert_eq!( - info.version, - format!( - "{} / {} / {}", - upend_base::common::build::PKG_VERSION, - upend_db::common::build::PKG_VERSION, - build::PKG_VERSION - ) - ); assert!(!info.desktop); }