Use a deterministic number of digits in rustc_tools_util commit hashes

This commit is contained in:
David Tolnay 2024-08-05 08:17:18 -07:00
parent c082bc2cb8
commit 9f6536ce6f
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -104,10 +104,11 @@ impl std::fmt::Debug for VersionInfo {
#[must_use] #[must_use]
pub fn get_commit_hash() -> Option<String> { pub fn get_commit_hash() -> Option<String> {
let output = std::process::Command::new("git") let output = std::process::Command::new("git")
.args(["rev-parse", "--short", "HEAD"]) .args(["rev-parse", "HEAD"])
.output() .output()
.ok()?; .ok()?;
let stdout = output.status.success().then_some(output.stdout)?; let mut stdout = output.status.success().then_some(output.stdout)?;
stdout.truncate(10);
String::from_utf8(stdout).ok() String::from_utf8(stdout).ok()
} }