-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version string verbosity #3240
Version string verbosity #3240
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,10 @@ fn version_from_git_info() -> Result<String, std::io::Error> { | |
|
||
// The last available tag, equal to exact_tag when | ||
// the current commit is tagged | ||
let last_tag = run(&["git", "describe", "--abbrev=0", "--tags"])?; | ||
println!("cargo:rustc-env=GIT_LAST_TAG={last_tag}"); | ||
let last_tag_maybe = run(&["git", "describe", "--abbrev=0", "--tags"]).ok(); | ||
if let Some(ref last_tag) = last_tag_maybe { | ||
println!("cargo:rustc-env=GIT_LAST_TAG={last_tag}"); | ||
} | ||
|
||
// The current branch name | ||
let branch = run(&["git", "rev-parse", "--abbrev-ref", "HEAD"])?; | ||
|
@@ -69,12 +71,25 @@ fn version_from_git_info() -> Result<String, std::io::Error> { | |
let rev_short = rev.get(..8).unwrap_or_default(); | ||
println!("cargo:rustc-env=GIT_REV={rev_short}"); | ||
|
||
// The current git commit time | ||
let commit_time = run(&["git", "log", "-1", "--format=%cd", "--date=format:%Y-%m-%d %H:%M:%S"])?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the commit time to the version string seems overly verbose, and isn't something that's usually included in a version string itself. While I don't feel that including the commit time is all that valuable, if you really want to include it, I think it should go on its own line of output, and it should also include timezone info. BTW, |
||
|
||
// Combined version | ||
if let Some(exact) = exact_tag { | ||
Ok(exact) | ||
} else if &branch != "main" && &branch != "master" { | ||
Ok(format!("{last_tag}-{rev_short} ({branch})")) | ||
if let Some(ref last_tag) = last_tag_maybe { | ||
Ok(format!("{last_tag}-{rev_short} ({branch}) {commit_time}")) | ||
} | ||
else { | ||
Ok(format!("{rev_short} ({branch}) {commit_time}")) | ||
} | ||
} else { | ||
Ok(format!("{last_tag}-{rev_short}")) | ||
if let Some(ref last_tag) = last_tag_maybe { | ||
Ok(format!("{last_tag}-{rev_short} {commit_time}")) | ||
} | ||
else { | ||
Ok(format!("main-{rev_short} {commit_time}")) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use https://crates.io/crates/vergen for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is maybe a nice one to use instead of our custom calls, and it could provide some more info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yean and its very easy to use, I use it on wdes/mail-autodiscover-autoconfig#3 (comment)
if examples are needed