From 297908e9503577ad93596f97ce306cbb7096acf7 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Mon, 3 May 2021 02:46:37 +0530 Subject: [PATCH] Remove git warning --- build.rs | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/build.rs b/build.rs index 04c6a5f..2537f3a 100644 --- a/build.rs +++ b/build.rs @@ -1,45 +1,19 @@ use std::env; use std::process::Command; -macro_rules! warn { - ($fmt:tt) => ({ - ::std::println!(::std::concat!("cargo:warning=", $fmt)); - }); - ($fmt:tt, $($arg:tt)*) => ({ - ::std::println!(::std::concat!("cargo:warning=", $fmt), $($arg)*); - }); -} - fn git_version() -> Option { + // Packages releases of zoxide almost always use the source tarball + // provided by GitHub, which does not include the `.git` folder. Since this + // feature is only useful for development, there's no need of printing a + // warning here. let mut git = Command::new("git"); git.args(&["describe", "--tags", "--broken"]); - let output = match git.output() { - Err(e) => { - warn!("when retrieving version: git failed to start: {}", e); - return None; - } - Ok(output) if !output.status.success() => { - warn!( - "when retrieving version: git exited with code: {:?}", - output.status.code() - ); - return None; - } - Ok(output) => output, - }; - - match String::from_utf8(output.stdout) { - Ok(version) => Some(version), - Err(e) => { - warn!("when retrieving version: git returned invalid utf-8: {}", e); - None - } - } + let output = git.output().ok()?; + String::from_utf8(output.stdout).ok() } fn crate_version() -> String { - warn!("falling back to crate version"); // unwrap is safe here, since Cargo will always supply this variable. format!("v{}", env::var("CARGO_PKG_VERSION").unwrap()) }