diff --git a/build.rs b/build.rs
index 2689b98..d9e9de4 100644
--- a/build.rs
+++ b/build.rs
@@ -1,5 +1,5 @@
use anyhow::{bail, Context};
-use std::env;
+use std::env::{var, VarError};
use std::io::ErrorKind;
use std::process::{Command, Stdio};
@@ -7,7 +7,11 @@ fn main() -> anyhow::Result<()> {
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/refs");
let pkg_version = getenv("CARGO_PKG_VERSION")?;
- match get_commit_hash()? {
+ let mut commit = get_commit_hash()?;
+ if commit.is_none() {
+ commit = get_heroku_slug_commit()?;
+ }
+ match commit {
Some(commit) => {
println!("cargo:rustc-env=GIT_COMMIT={commit}");
println!("cargo:rustc-env=VERSION_WITH_GIT={pkg_version} (commit: {commit})");
@@ -58,6 +62,14 @@ fn get_commit_hash() -> anyhow::Result