-
-
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
Conversation
@@ -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(); |
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
Besides the tests that are failing. There is an env variable that can be set if it is known to not having a full git clone. |
@@ -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 comment
The 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, hooks/build
already includes the build (not commit) time in the Docker image. To me it seems a bit odd for those times not to match, so that's another reason I'd favor not including the commit time.
I have looked into If some maintainer or builder is using a shallow pull they should export Going to close this as we are not going to implement this. |
Build script doesn't produce version string if no git history is available.
Steps to reproduce:
git clone --depth 1 https://github.com/dani-garcia/vaultwarden.git
docker build --build-arg DB=sqlite -f docker/amd64/Dockerfile -t vaultwarden:local .
docker run -it --rm vaultwarden:local
Actual result: no version information in output
After this PR:
Description:
Four types of version string are generated in build.rs:
{last_tag}-{rev_short} {commit_time}
main-{rev_short} {commit_time}
{last_tag}-{rev_short} ({branch}) {commit_time}
{rev_short} ({branch}) {commit_time}