Show Git SHA information when printing version information (#120)

This commit is contained in:
Ulyssa 2023-06-14 20:28:01 -07:00
parent a020b860dd
commit 2a573b6056
No known key found for this signature in database
GPG key ID: 1B3965A3D18B9B64
5 changed files with 38 additions and 2 deletions

18
Cargo.lock generated
View file

@ -1529,6 +1529,7 @@ dependencies = [
"unicode-segmentation",
"unicode-width",
"url",
"vergen",
]
[[package]]
@ -3135,6 +3136,12 @@ dependencies = [
"base64 0.21.0",
]
[[package]]
name = "rustversion"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06"
[[package]]
name = "ryu"
version = "1.0.13"
@ -3974,6 +3981,17 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vergen"
version = "8.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b3c89c2c7e50f33e4d35527e5bf9c11d6d132226dbbd1753f0fbe9f19ef88c6"
dependencies = [
"anyhow",
"rustversion",
"time 0.3.20",
]
[[package]]
name = "version_check"
version = "0.9.4"

View file

@ -12,6 +12,12 @@ exclude = [".github", "CONTRIBUTING.md"]
keywords = ["matrix", "chat", "tui", "vim"]
categories = ["command-line-utilities"]
rust-version = "1.66"
build = "build.rs"
[build-dependencies.vergen]
version = "8"
default-features = false
features = ["build", "git", "gitcl",]
[dependencies]
arboard = "3.2.0"

7
build.rs Normal file
View file

@ -0,0 +1,7 @@
use std::error::Error;
use vergen::EmitBuilder;
fn main() -> Result<(), Box<dyn Error>> {
EmitBuilder::builder().git_sha(true).emit()?;
Ok(())
}

View file

@ -89,8 +89,13 @@ fn validate_profile_names(names: &HashMap<String, ProfileConfig>) {
}
}
const VERSION: &str = match option_env!("VERGEN_GIT_SHA") {
None => env!("CARGO_PKG_VERSION"),
Some(_) => concat!(env!("CARGO_PKG_VERSION"), " (", env!("VERGEN_GIT_SHA"), ")"),
};
#[derive(Parser)]
#[clap(version, about, long_about = None)]
#[clap(version = VERSION, about, long_about = None)]
#[clap(propagate_version = true)]
pub struct Iamb {
#[clap(short = 'P', long, value_parser)]

View file

@ -538,7 +538,7 @@ impl Window<IambInfo> for IambWindow {
title.into(),
];
Spans(v)
}
},
}
}