Omit git version hash when git command fails

This commit is contained in:
nibon7 2022-02-22 21:08:49 +08:00 committed by GitHub
parent 36e981ad4b
commit 8ea6c3bc52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -28,6 +28,7 @@ fn commit_hash() -> Option<String> {
.args(&["rev-parse", "--short", "HEAD"])
.output()
.ok()
.filter(|output| output.status.success())
.and_then(|output| String::from_utf8(output.stdout).ok())
.map(|hash| hash.trim().into())
}