generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Diane Huxley
committed
Aug 15, 2024
1 parent
d7558e4
commit 367b6d4
Showing
3 changed files
with
22 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::process::Command; | ||
use std::env; | ||
|
||
fn main() { | ||
// Execute the `git rev-parse HEAD` command to get the current commit hash | ||
let output = Command::new("git") | ||
.args(&["rev-parse", "HEAD"]) | ||
.output() | ||
.expect("Failed to execute git command"); | ||
|
||
// Convert the output to a string | ||
let git_hash = String::from_utf8(output.stdout).expect("Invalid UTF-8 sequence"); | ||
|
||
// Remove the newline character from the commit hash | ||
let git_hash_trimmed = git_hash.trim(); | ||
|
||
// Pass the commit hash to the compiler as an environment variable | ||
println!("cargo:rustc-env=WEB5_GIT_COMMIT_HASH={}", git_hash_trimmed); | ||
} |
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