Skip to content

Commit f82e935

Browse files
committed
option_env and commit_info
1 parent ef05a2d commit f82e935

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

rustfmt-bin/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ 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!("{} ({} {})", channel(), hash.trim_right(), date),
29+
match (channel(), commit_hash(), commit_date()) {
30+
(channel, Some(hash), Some(date)) => format!("{} ({} {})", channel, hash.trim_right(), date),
3131
_ => String::new(),
3232
}
3333
}

rustfmt-bin/src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,14 @@ fn print_usage_to_stdout(opts: &Options, reason: &str) {
386386
}
387387

388388
fn print_version() {
389-
println!(
390-
"rustfmt {}",
391-
concat!(
392-
env!("CARGO_PKG_VERSION"),
393-
"-",
394-
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
395-
)
389+
let version_info = format!(
390+
"{}{}{}",
391+
option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"),
392+
"-",
393+
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
396394
);
395+
396+
println!("rustfmt {}", version_info);
397397
}
398398

399399
fn determine_operation(matches: &Matches) -> FmtResult<Operation> {

0 commit comments

Comments
 (0)