-
Notifications
You must be signed in to change notification settings - Fork 737
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63791b4
commit 9f4cc70
Showing
1 changed file
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |