From b9f0d80dc30936a75f6627e9b3299186a02820b1 Mon Sep 17 00:00:00 2001 From: blek Date: Sun, 29 Oct 2023 19:13:27 +1000 Subject: [PATCH] move out code to a function --- filed/build.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/filed/build.rs b/filed/build.rs index 13b1c0c..fde6fbd 100644 --- a/filed/build.rs +++ b/filed/build.rs @@ -17,6 +17,14 @@ fn extfilter(valid: String, x: Option<&OsStr>) -> bool { ext == valid } +fn system(cmd: &str, args: &[&str]) -> String { + let out = Command::new(cmd) + .args(args) + .output() + .unwrap(); + String::from_utf8(out.stdout).unwrap() +} + fn main() { println!("cargo:rerun-if-changed=static/assets"); @@ -60,11 +68,7 @@ fn main() { .unwrap(); }); - let commit = Command::new("git") - .args(&["rev-parse", "HEAD"]) - .output() - .unwrap(); + let commit = system("git", &["rev-parse", "HEAD"]); - let commit = String::from_utf8(commit.stdout).unwrap(); println!("cargo:rustc-env=COMMIT_HASH={commit}"); } \ No newline at end of file