-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
27 lines (27 loc) · 847 Bytes
/
Copy pathbuild.rs
File metadata and controls
27 lines (27 loc) · 847 Bytes
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
27
use std::process::Command;
fn main() {
let git_hash = String::from_utf8(
Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.expect("Failed to execute `git rev-parse HEAD`")
.stdout,
)
.expect("Git output is not valid UTF-8");
let is_dirty = !{
Command::new("git")
.args(["status", "--porcelain"])
.output()
.expect("Failed to execute `git status --porcelain`")
.stdout
.is_empty()
};
println!(
"cargo:rustc-env=GIT_HASH={}{}",
git_hash.trim(),
if is_dirty { "-drity" } else { "" }
);
println!("cargo:rustc-rerun-if-changed=.git/HEAD");
println!("cargo:rustc-rerun-if-changed=.git/index");
println!("cargo:rustc-rerun-if-changed=.git/refs/heads/");
}