Skip to content

Commit

Permalink
allow building wihtout a git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror committed Aug 17, 2024
1 parent 63791b4 commit 9f4cc70
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions extension/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
fn main() {
let repo = git2::Repository::open("../").expect("Open git repo");
let head = repo
.head()
.expect("Get HEAD")
.target()
.expect("Get HEAD target");
let commit = repo.find_commit(head).expect("Find commit");
println!("cargo:rustc-env=GIT_HASH={}", commit.id());
if let Ok(repo) = git2::Repository::open("../") {
let head = repo
.head()
.expect("Get HEAD")
.target()
.expect("Get HEAD target");
let commit = repo.find_commit(head).expect("Find commit");
println!("cargo:rustc-env=GIT_HASH={}", commit.id());
} else {
println!("cargo:rustc-env=GIT_HASH=GIT_REPO_FAILURE");
}
}

0 comments on commit 9f4cc70

Please sign in to comment.