diff --git a/src/api/server_server.rs b/src/api/server_server.rs index daba63ff..b6fe20b3 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -515,7 +515,7 @@ pub(crate) async fn get_server_version_route( Ok(get_server_version::v1::Response { server: Some(get_server_version::v1::Server { name: Some(env!("CARGO_PKG_NAME").to_owned()), - version: Some(env!("CARGO_PKG_VERSION").to_owned()), + version: Some(crate::version()), }), }) } diff --git a/src/clap.rs b/src/clap.rs index f38d162a..09cd3839 100644 --- a/src/clap.rs +++ b/src/clap.rs @@ -2,23 +2,9 @@ use clap::Parser; -/// Returns the current version of the crate with extra info if supplied -/// -/// Set the environment variable `GRAPEVINE_VERSION_EXTRA` to any UTF-8 string to -/// include it in parenthesis after the SemVer version. A common value are git -/// commit hashes. -fn version() -> String { - let cargo_pkg_version = env!("CARGO_PKG_VERSION"); - - match option_env!("GRAPEVINE_VERSION_EXTRA") { - Some(x) => format!("{cargo_pkg_version} ({x})"), - None => cargo_pkg_version.to_owned(), - } -} - /// Command line arguments #[derive(Parser)] -#[clap(about, version = version())] +#[clap(about, version = crate::version())] pub(crate) struct Args; /// Parse command line arguments into structured data diff --git a/src/main.rs b/src/main.rs index def5a85a..d445d207 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,6 +71,20 @@ pub(crate) fn services() -> &'static Services { .expect("SERVICES should be initialized when this is called") } +/// Returns the current version of the crate with extra info if supplied +/// +/// Set the environment variable `GRAPEVINE_VERSION_EXTRA` to any UTF-8 string to +/// include it in parenthesis after the SemVer version. A common value are git +/// commit hashes. +fn version() -> String { + let cargo_pkg_version = env!("CARGO_PKG_VERSION"); + + match option_env!("GRAPEVINE_VERSION_EXTRA") { + Some(x) => format!("{cargo_pkg_version} ({x})"), + None => cargo_pkg_version.to_owned(), + } +} + #[tokio::main] async fn main() { clap::parse();