Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-loader/build.rs')
-rw-r--r--helix-loader/build.rs25
1 files changed, 10 insertions, 15 deletions
diff --git a/helix-loader/build.rs b/helix-loader/build.rs
index 22f2fa8f..a4562c00 100644
--- a/helix-loader/build.rs
+++ b/helix-loader/build.rs
@@ -6,26 +6,23 @@ 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"])
.output()
.ok()
.filter(|output| output.status.success())
- .and_then(|x| String::from_utf8(x.stdout).ok())
- .or_else(|| option_env!("HELIX_NIX_BUILD_REV").map(|s| s.to_string()));
+ .and_then(|x| String::from_utf8(x.stdout).ok());
- 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 calver = get_calver();
let version: Cow<_> = match &git_hash {
Some(git_hash) => format!("{} ({})", calver, &git_hash[..8]).into(),
None => calver.into(),
@@ -53,7 +50,6 @@ fn main() {
.ok()
.filter(|output| output.status.success())
.and_then(|x| String::from_utf8(x.stdout).ok())
- .map(|x| x.trim().to_string())
else {
return;
};
@@ -71,7 +67,6 @@ fn main() {
.ok()
.filter(|output| output.status.success())
.and_then(|x| String::from_utf8(x.stdout).ok())
- .map(|x| x.trim().to_string())
else {
return;
};