Configure structopt to report the right version

By default, structopt reports the value provided by
the env var CARGO_PKG_VERSION, feeded by Cargo when reading
Cargo.toml. However for Garage we use a versioning based on git,
so we often report a version that is behind the real version.
In this commit, we create garage_util::version::garage() that
reports the right version and configure all structopt subcommands
to call this function instead of using the env var.
This commit is contained in:
Quentin Dufour
2022-08-10 12:18:44 +02:00
parent 8cd02639dc
commit 2c7bae935a
12 changed files with 97 additions and 90 deletions
+2
View File
@@ -24,6 +24,7 @@ hex = "0.4"
tracing = "0.1.30"
rand = "0.8"
sha2 = "0.9"
git-version = "0.3.4"
chrono = "0.4"
rmp-serde = "0.15"
@@ -43,5 +44,6 @@ hyper = "0.14"
opentelemetry = { version = "0.17", features = [ "rt-tokio", "metrics", "trace" ] }
[features]
k2v = []
+1
View File
@@ -14,3 +14,4 @@ pub mod persister;
pub mod time;
pub mod token_bucket;
pub mod tranquilizer;
pub mod version;
+7
View File
@@ -0,0 +1,7 @@
pub fn garage() -> &'static str {
option_env!("GIT_VERSION").unwrap_or(git_version::git_version!(
prefix = "git:",
cargo_prefix = "cargo:",
fallback = "unknown"
))
}