forked from greshake/i3status-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
26 lines (24 loc) · 812 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::process::Command;
fn main() {
let output = Command::new("git")
.args(&["rev-parse", "--short", "HEAD"])
.env("GIT_CONFIG_GLOBAL", "/dev/null")
.output();
let hash = match output {
Ok(o) => String::from_utf8(o.stdout).unwrap(),
Err(_) => String::from(""),
};
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", hash);
let output = Command::new("git")
.args(&["log", "--pretty=format:'%ad'", "-n1", "--date=short"])
.env("GIT_CONFIG_GLOBAL", "/dev/null")
.output();
let date = match output {
Ok(o) => String::from_utf8(o.stdout)
.unwrap()
.trim_matches('\'')
.to_string(),
Err(_) => String::from(""),
};
println!("cargo:rustc-env=GIT_COMMIT_DATE={}", date);
}