Skip to content

Commit 15c75fe

Browse files
dtolnayytmimi
authored andcommitted
Check exit status of git commands spawned by build script
1 parent 17c5869 commit 15c75fe

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

build.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ fn commit_hash() -> Option<String> {
4343
.args(["rev-parse", "HEAD"])
4444
.output()
4545
.ok()?;
46-
let mut stdout = String::from_utf8(output.stdout).ok()?;
46+
let mut stdout = output.status.success().then_some(output.stdout)?;
4747
stdout.truncate(10);
48-
Some(stdout)
48+
String::from_utf8(stdout).ok()
4949
}
5050

5151
fn commit_date() -> Option<String> {
52-
Command::new("git")
52+
let output = Command::new("git")
5353
.args(["log", "-1", "--date=short", "--pretty=format:%cd"])
5454
.output()
55-
.ok()
56-
.and_then(|r| String::from_utf8(r.stdout).ok())
55+
.ok()?;
56+
let stdout = output.status.success().then_some(output.stdout)?;
57+
String::from_utf8(stdout).ok()
5758
}

0 commit comments

Comments
 (0)