forge
Explore
Log in

Don't you dare go Hollow

Format version as calver automatically

Browse files at this commit

e35c630c1d2fe9621cc43dd86596aaaca8a56d2eIvan MolodetskikhParent: d3047af
src/utils/mod.rsmodified+16 -2
@@ -83,11 +83,25 @@ pub fn version() -> String {
8383 return String::from(v);
8484 }
8585
86- let version = env!("CARGO_PKG_VERSION");
86+ const MAJOR: &str = env!("CARGO_PKG_VERSION_MAJOR");
87+ const MINOR: &str = env!("CARGO_PKG_VERSION_MINOR");
88+ const PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");
89+
90+ let minor_prefix = if MINOR.len() == 1 {
91+ // Print single-digit months in '0M' format.
92+ "0"
93+ } else {
94+ ""
95+ };
96+
8797 let commit =
8898 option_env!("NIRI_BUILD_COMMIT").unwrap_or(git_version!(fallback = "unknown commit"));
8999
90- format!("{version} ({commit})")
100+ if PATCH == "0" {
101+ format!("{MAJOR}.{minor_prefix}{MINOR} ({commit})")
102+ } else {
103+ format!("{MAJOR}.{minor_prefix}{MINOR}.{PATCH} ({commit})")
104+ }
91105 }
92106
93107 pub fn get_monotonic_time() -> Duration {