Check exit status of git commands spawned by build script
This commit is contained in:
parent
17c5869dff
commit
15c75fec4f
11
build.rs
11
build.rs
@ -43,15 +43,16 @@ fn commit_hash() -> Option<String> {
|
|||||||
.args(["rev-parse", "HEAD"])
|
.args(["rev-parse", "HEAD"])
|
||||||
.output()
|
.output()
|
||||||
.ok()?;
|
.ok()?;
|
||||||
let mut stdout = String::from_utf8(output.stdout).ok()?;
|
let mut stdout = output.status.success().then_some(output.stdout)?;
|
||||||
stdout.truncate(10);
|
stdout.truncate(10);
|
||||||
Some(stdout)
|
String::from_utf8(stdout).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn commit_date() -> Option<String> {
|
fn commit_date() -> Option<String> {
|
||||||
Command::new("git")
|
let output = Command::new("git")
|
||||||
.args(["log", "-1", "--date=short", "--pretty=format:%cd"])
|
.args(["log", "-1", "--date=short", "--pretty=format:%cd"])
|
||||||
.output()
|
.output()
|
||||||
.ok()
|
.ok()?;
|
||||||
.and_then(|r| String::from_utf8(r.stdout).ok())
|
let stdout = output.status.success().then_some(output.stdout)?;
|
||||||
|
String::from_utf8(stdout).ok()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user