fix: fix vergen output in component template#131
fix: fix vergen output in component template#131JayanAXHF wants to merge 1 commit intoratatui:mainfrom
Conversation
JayanAXHF
left a comment
There was a problem hiding this comment.
I've tested this workaround on my project and it works!
There was a problem hiding this comment.
This is probably because of just-generate
| [build-dependencies] | ||
| anyhow = "1.0.90" | ||
| vergen-gix = { version = "9.1.0", features = ["build", "cargo"] } | ||
| vergen-gix = { version = "10.0.0-beta.5", features = ["build", "cargo", "allow_remote"] } |
There was a problem hiding this comment.
Any idea when 10.0.0 is going to be out? I'm a bit hesitant about including a beta dependency in a template
Alsol, I was under the impression that there should be a simpler fix for this. e.g. if VERGEN_GIT_DESCRIBE is not available, we use another string for the version message.
There was a problem hiding this comment.
Any idea when 10.0.0 is going to be out? I'm a bit hesitant about including a beta dependency in a template
Understandable, i'm currently unaware of a planned release timeline, so we could keep this PR here until it stablises.
Alsol, I was under the impression that there should be a simpler fix for this. e.g. if
VERGEN_GIT_DESCRIBEis not available, we use another string for the version message.
The problem is that we can't use any VERGEN_GIT_* strings, we'd have to rely on the cargo version and build info for a good version string.
There was a problem hiding this comment.
We could maybe use option_env like this?
diff --git a/component-generated/src/cli.rs b/component-generated/src/cli.rs
index 8696a0a..336a864 100644
--- a/component-generated/src/cli.rs
+++ b/component-generated/src/cli.rs
@@ -14,14 +14,17 @@ pub struct Cli {
pub frame_rate: f64,
}
-const VERSION_MESSAGE: &str = concat!(
- env!("CARGO_PKG_VERSION"),
- "-",
- env!("VERGEN_GIT_DESCRIBE"),
- " (",
- env!("VERGEN_BUILD_DATE"),
- ")"
-);
+fn version_message() -> String {
+ let git_describe = option_env!("VERGEN_GIT_DESCRIBE")
+ .map(|describe| format!("-{describe}"))
+ .unwrap_or_default();
+ format!(
+ "{}{} ({})",
+ env!("CARGO_PKG_VERSION"),
+ git_describe,
+ env!("VERGEN_BUILD_DATE")
+ )
+}
pub fn version() -> String {
let author = clap::crate_authors!();
@@ -32,11 +35,12 @@ pub fn version() -> String {
format!(
"\
-{VERSION_MESSAGE}
+{}
Authors: {author}
Config directory: {config_dir_path}
-Data directory: {data_dir_path}"
+Data directory: {data_dir_path}",
+ version_message()
)
}
Closes #130