Skip to content

Commit b7bc720

Browse files
authored
Merge pull request #2540 from topecongiro/version
Fix print_version
2 parents 87180d9 + ca6fc67 commit b7bc720

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

build.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,22 @@ fn main() {
2626
// Try to get hash and date of the last commit on a best effort basis. If anything goes wrong
2727
// (git not installed or if this is not a git repository) just return an empty string.
2828
fn commit_info() -> String {
29-
match (commit_hash(), commit_date()) {
30-
(Some(hash), Some(date)) => format!(" ({} {})", hash.trim_right(), date),
29+
match (channel(), commit_hash(), commit_date()) {
30+
(channel, Some(hash), Some(date)) => {
31+
format!("{} ({} {})", channel, hash.trim_right(), date)
32+
}
3133
_ => String::new(),
3234
}
3335
}
3436

37+
fn channel() -> String {
38+
if let Ok(channel) = env::var("CFG_RELEASE_CHANNEL") {
39+
channel
40+
} else {
41+
"nightly".to_owned()
42+
}
43+
}
44+
3545
fn commit_hash() -> Option<String> {
3646
Command::new("git")
3747
.args(&["rev-parse", "--short", "HEAD"])

src/bin/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,8 @@ fn print_usage_to_stdout(opts: &Options, reason: &str) {
385385

386386
fn print_version() {
387387
let version_info = format!(
388-
"{}{}{}",
388+
"{}-{}",
389389
option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"),
390-
"-",
391390
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
392391
);
393392

0 commit comments

Comments
 (0)