mirror of https://github.com/helix-editor/helix
Format '--version' calendar version as 'YY.0M'
We use calendar versioning which isn't supported by Cargo, so we need to add an extra leading zero to the month for releases between January and September to match our usual 'YY.0M' formatting. Closes #12414pull/11374/merge
parent
6c9619d094
commit
03f35af9c1
|
@ -6,14 +6,6 @@ const MAJOR: &str = env!("CARGO_PKG_VERSION_MAJOR");
|
|||
const MINOR: &str = env!("CARGO_PKG_VERSION_MINOR");
|
||||
const PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");
|
||||
|
||||
fn get_calver() -> String {
|
||||
if PATCH == "0" {
|
||||
format!("{MAJOR}.{MINOR}")
|
||||
} else {
|
||||
format!("{MAJOR}.{MINOR}.{PATCH}")
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let git_hash = Command::new("git")
|
||||
.args(["rev-parse", "HEAD"])
|
||||
|
@ -23,7 +15,17 @@ fn main() {
|
|||
.and_then(|x| String::from_utf8(x.stdout).ok())
|
||||
.or_else(|| option_env!("HELIX_NIX_BUILD_REV").map(|s| s.to_string()));
|
||||
|
||||
let calver = get_calver();
|
||||
let minor = if MINOR.len() == 1 {
|
||||
// Print single-digit months in '0M' format
|
||||
format!("0{MINOR}")
|
||||
} else {
|
||||
MINOR.to_string()
|
||||
};
|
||||
let calver = if PATCH == "0" {
|
||||
format!("{MAJOR}.{minor}")
|
||||
} else {
|
||||
format!("{MAJOR}.{minor}.{PATCH}")
|
||||
};
|
||||
let version: Cow<_> = match &git_hash {
|
||||
Some(git_hash) => format!("{} ({})", calver, &git_hash[..8]).into(),
|
||||
None => calver.into(),
|
||||
|
|
Loading…
Reference in New Issue