diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d37ff7..5cf95e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..b9ae403 --- /dev/null +++ b/build.rs @@ -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); +} diff --git a/src/main.rs b/src/main.rs index a480b45..012f85c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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),