Skip to content

Commit f3d4131

Browse files
author
Junfeng Li
committed
Use read_to_string.
1 parent 8eed47d commit f3d4131

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

build.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
use std::process::Command;
2-
3-
fn git_hash() -> String {
4-
let output = Command::new("cat")
5-
.args(&[".git/refs/heads/next"])
6-
.output()
7-
.unwrap();
8-
String::from_utf8_lossy(&output.stdout).into()
9-
}
1+
use std::fs::read_to_string;
102

113
fn main() {
124
let git_hash = option_env!("TRAVIS_COMMIT")
135
.map(|s| s.into())
14-
.unwrap_or_else(|| git_hash());
6+
.unwrap_or_else(|| read_to_string(".git/refs/heads/next").unwrap_or_default());
157

168
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
179
}

0 commit comments

Comments
 (0)