move out code to a function

This commit is contained in:
blek 2023-10-29 19:13:27 +10:00
parent 98c22d2408
commit 6904a670a8
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 9 additions and 5 deletions

View File

@ -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}");
}