From ca6fc67e6015b14efba03a0b580ee40ffaff2a29 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Sat, 17 Mar 2018 12:16:15 +0900 Subject: [PATCH] Fix print_version --- build.rs | 14 ++++++++++++-- src/bin/main.rs | 3 +-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 2643946236d..d72b44eb7f3 100644 --- a/build.rs +++ b/build.rs @@ -26,12 +26,22 @@ fn main() { // Try to get hash and date of the last commit on a best effort basis. If anything goes wrong // (git not installed or if this is not a git repository) just return an empty string. fn commit_info() -> String { - match (commit_hash(), commit_date()) { - (Some(hash), Some(date)) => format!(" ({} {})", hash.trim_right(), date), + match (channel(), commit_hash(), commit_date()) { + (channel, Some(hash), Some(date)) => { + format!("{} ({} {})", channel, hash.trim_right(), date) + } _ => String::new(), } } +fn channel() -> String { + if let Ok(channel) = env::var("CFG_RELEASE_CHANNEL") { + channel + } else { + "nightly".to_owned() + } +} + fn commit_hash() -> Option { Command::new("git") .args(&["rev-parse", "--short", "HEAD"]) diff --git a/src/bin/main.rs b/src/bin/main.rs index 4a49ce5a2e6..c89c25a90fe 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -385,9 +385,8 @@ fn print_usage_to_stdout(opts: &Options, reason: &str) { fn print_version() { let version_info = format!( - "{}{}{}", + "{}-{}", option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"), - "-", include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")) );