We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 90b4ec6 commit a77c85dCopy full SHA for a77c85d
1 file changed
build.rs
@@ -18,12 +18,12 @@ fn main() -> Result<()> {
18
// Supply information as compile-time environment variables.
19
#[cfg(feature = "opa-runtime")]
20
{
21
- let output = std::process::Command::new("git")
+ let git_hash = std::process::Command::new("git")
22
.args(["rev-parse", "HEAD"])
23
.output()
24
- .expect("`git rev-parse HEAD` failed.");
25
- let git_hash = String::from_utf8(output.stdout).unwrap();
26
- println!("cargo:rustc-env=GIT_HASH={git_hash}");
+ .map(|output| String::from_utf8_lossy(&output.stdout).trim().to_string())
+ .unwrap_or_else(|_| "unknown".to_string());
+ println!("cargo:rustc-env=GIT_HASH={}", git_hash);
27
}
28
29
// Rerun only if build.rs changes.
0 commit comments