chore: persist activity feed history and improve build versioning
This commit is contained in:
1 parent
e72af4f877
commit
cb8447224f
2 files changed
+44
-10
No files matched your search
+14
-10
@@ -1,25 +1,29 @@
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
let git_hash = Command::new("git")
|
||||
let mut git_hash = Command::new("git")
|
||||
.args(["rev-parse", "--short", "HEAD"])
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|out| String::from_utf8(out.stdout).ok())
|
||||
.unwrap_or_else(|| "unknown".to_string());
|
||||
|
||||
git_hash = git_hash.trim().to_string();
|
||||
|
||||
let git_date = Command::new("git")
|
||||
.args(["log", "-1", "--format=%cd", "--date=format:%y.%m.%d.%H%M%S"])
|
||||
let is_dirty = Command::new("git")
|
||||
.args(["status", "--porcelain"])
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|out| String::from_utf8(out.stdout).ok())
|
||||
.unwrap_or_else(|| "unknown".to_string());
|
||||
.map(|out| !out.stdout.is_empty())
|
||||
.unwrap_or(false);
|
||||
|
||||
let version = format!(
|
||||
"{} ({})",
|
||||
git_date.trim(),
|
||||
git_hash.trim()
|
||||
);
|
||||
if is_dirty {
|
||||
git_hash.push_str("-dirty");
|
||||
}
|
||||
|
||||
let build_date = chrono::Local::now().format("%y.%m.%d.%H%M%S").to_string();
|
||||
|
||||
let version = format!("{} ({})", build_date, git_hash);
|
||||
println!("cargo:rustc-env=APP_VERSION={}", version);
|
||||
|
||||
if std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default() == "windows" {
|
||||
|
||||
Reference in new issue
Block a user