Show commit hash in version number

This commit is contained in:
Cole Helbling 2020-03-31 14:54:45 -07:00 committed by GitHub
parent 0191eead52
commit 1e333dfb33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Version output displays `git` revision information.
## [0.3.0] - 2020-03-30
### Added

14
build.rs Normal file
View File

@ -0,0 +1,14 @@
fn main() {
let git_describe = std::process::Command::new("git")
.args(&["describe", "--tags", "--broken"])
.output()
.ok()
.and_then(|proc| String::from_utf8(proc.stdout).ok());
let version_info = match git_describe {
Some(description) if !description.is_empty() => description,
_ => format!("v{}-unknown", env!("CARGO_PKG_VERSION")),
};
println!("cargo:rustc-env=ZOXIDE_VERSION={}", version_info);
}

View File

@ -8,7 +8,7 @@ use anyhow::Result;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(about = "A cd command that learns your habits")]
#[structopt(about = "A cd command that learns your habits", version = env!("ZOXIDE_VERSION"))]
enum Zoxide {
Add(subcommand::Add),
Import(subcommand::Import),