Skip to content

Commit ef05a2d

Browse files
committed
explict version informations
1 parent 383e7e9 commit ef05a2d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

rustfmt-bin/build.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,19 @@ fn main() {
2727
// (git not installed or if this is not a git repository) just return an empty string.
2828
fn commit_info() -> String {
2929
match (commit_hash(), commit_date()) {
30-
(Some(hash), Some(date)) => format!(" ({} {})", hash.trim_right(), date),
30+
(Some(hash), Some(date)) => format!("{} ({} {})", channel(), hash.trim_right(), date),
3131
_ => String::new(),
3232
}
3333
}
3434

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

rustfmt-bin/src/main.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,13 @@ fn print_usage_to_stdout(opts: &Options, reason: &str) {
387387

388388
fn print_version() {
389389
println!(
390-
"{}-nightly{}",
391-
option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"),
392-
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
393-
)
390+
"rustfmt {}",
391+
concat!(
392+
env!("CARGO_PKG_VERSION"),
393+
"-",
394+
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
395+
)
396+
);
394397
}
395398

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

0 commit comments

Comments
 (0)