Skip to content

Commit

Permalink
Check exit status of git commands spawned by build script
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay authored and ytmimi committed Aug 4, 2024
1 parent 17c5869 commit 15c75fe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ fn commit_hash() -> Option<String> {
.args(["rev-parse", "HEAD"])
.output()
.ok()?;
let mut stdout = String::from_utf8(output.stdout).ok()?;
let mut stdout = output.status.success().then_some(output.stdout)?;
stdout.truncate(10);
Some(stdout)
String::from_utf8(stdout).ok()
}

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

0 comments on commit 15c75fe

Please sign in to comment.