Show commit hash in version when built from source
Users might file an issue while running an older version, but the issue
has already been fixed in master. Adding the git revision to the version
output will expedite this diagnosis. For example:
$ zoxide -V
zoxide 0.3.0-0191eea
This commit is contained in:
parent
0191eead52
commit
030bb57924
|
|
@ -0,0 +1,14 @@
|
||||||
|
fn main() {
|
||||||
|
let mut hash = std::process::Command::new("git")
|
||||||
|
.args(&["rev-parse", "--short", "HEAD"])
|
||||||
|
.output()
|
||||||
|
.ok()
|
||||||
|
.and_then(|proc| String::from_utf8(proc.stdout).ok())
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
if !hash.is_empty() {
|
||||||
|
hash = format!("-{}", hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("cargo:rustc-env=GIT_HASH={}", hash);
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,10 @@ use anyhow::Result;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, StructOpt)]
|
||||||
#[structopt(about = "A cd command that learns your habits")]
|
#[structopt(
|
||||||
|
about = "A cd command that learns your habits",
|
||||||
|
version = concat!(env!("CARGO_PKG_VERSION"), env!("GIT_HASH"))
|
||||||
|
)]
|
||||||
enum Zoxide {
|
enum Zoxide {
|
||||||
Add(subcommand::Add),
|
Add(subcommand::Add),
|
||||||
Import(subcommand::Import),
|
Import(subcommand::Import),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue