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 {
83 return String::from(v);83 return String::from(v);
84 }84 }
85 85
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+
87 let commit =97 let commit =
88 option_env!("NIRI_BUILD_COMMIT").unwrap_or(git_version!(fallback = "unknown commit"));98 option_env!("NIRI_BUILD_COMMIT").unwrap_or(git_version!(fallback = "unknown commit"));
89 99
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+ }
91 }105 }
92 106
93 pub fn get_monotonic_time() -> Duration {107 pub fn get_monotonic_time() -> Duration {