mirror of
https://seed.radicle.dev/rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE.git
synced 2026-10-18 19:10:37 +08:00
feat: --version output now includes Git commit
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
// Set a build-time `GIT_HEAD` env var which includes the commit id;
|
||||
// such that we can tell which code is running.
|
||||
let hash = Command::new("git")
|
||||
.arg("rev-parse")
|
||||
.arg("--short")
|
||||
.arg("HEAD")
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|output| {
|
||||
if output.status.success() {
|
||||
String::from_utf8(output.stdout).ok()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| String::from("unknown"));
|
||||
|
||||
println!("cargo:rustc-env=GIT_HEAD={hash}");
|
||||
println!(
|
||||
"cargo:rustc-env=VERSION={}@{hash}",
|
||||
env!("CARGO_PKG_VERSION")
|
||||
);
|
||||
println!("cargo:rustc-rerun-if-changed=.git/HEAD");
|
||||
}
|
||||
@@ -55,7 +55,7 @@ fn fallible_main() -> Result<bool, EngineError> {
|
||||
} else {
|
||||
for arg in args.iter() {
|
||||
match arg.as_str() {
|
||||
"--version" => println!("{} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")),
|
||||
"--version" => println!("{} {}", env!("CARGO_PKG_NAME"), env!("VERSION")),
|
||||
"--show-config" => {
|
||||
let engine = Engine::new()?;
|
||||
println!("{}", engine.config().as_json());
|
||||
|
||||
Reference in New Issue
Block a user