Skip to content

fix: fix vergen output in component template#131

Open
JayanAXHF wants to merge 1 commit intoratatui:mainfrom
JayanAXHF:main
Open

fix: fix vergen output in component template#131
JayanAXHF wants to merge 1 commit intoratatui:mainfrom
JayanAXHF:main

Conversation

@JayanAXHF
Copy link
Copy Markdown

Closes #130

Copy link
Copy Markdown
Author

@JayanAXHF JayanAXHF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this workaround on my project and it works!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"] }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_DESCRIBE is 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
     )
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: The version message for the components template is erroneous

2 participants