Skip to content

Commit

Permalink
use standard padding syntax instead of implementing our own
Browse files Browse the repository at this point in the history
the padding of the two-digit-month can be implemented much more
concisely using `std::fmt` syntax.
  • Loading branch information
sodiboo authored and YaLTeR committed Jan 12, 2025
1 parent e05bc26 commit 6e41220
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,13 @@ pub fn version() -> String {
const MINOR: &str = env!("CARGO_PKG_VERSION_MINOR");
const PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");

let minor_prefix = if MINOR.len() == 1 {
// Print single-digit months in '0M' format.
"0"
} else {
""
};

let commit =
option_env!("NIRI_BUILD_COMMIT").unwrap_or(git_version!(fallback = "unknown commit"));

if PATCH == "0" {
format!("{MAJOR}.{minor_prefix}{MINOR} ({commit})")
format!("{MAJOR}.{MINOR:0>2} ({commit})")
} else {
format!("{MAJOR}.{minor_prefix}{MINOR}.{PATCH} ({commit})")
format!("{MAJOR}.{MINOR:0>2}.{PATCH} ({commit})")
}
}

Expand Down

0 comments on commit 6e41220

Please sign in to comment.