Skip to content

Commit

Permalink
Print empty commit info without trailing hyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay authored and ytmimi committed Aug 4, 2024
1 parent 15c75fe commit 8894466
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,14 @@ are included as out of line modules from `src/lib.rs`."
}

fn print_version() {
let version_info = format!(
"{}-{}",
option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"),
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
);
let version_number = option_env!("CARGO_PKG_VERSION").unwrap_or("unknown");
let commit_info = include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"));

println!("rustfmt {version_info}");
if commit_info.is_empty() {
println!("rustfmt {version_number}");
} else {
println!("rustfmt {version_number}-{commit_info}");
}
}

fn determine_operation(matches: &Matches) -> Result<Operation, OperationError> {
Expand Down

0 comments on commit 8894466

Please sign in to comment.