-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(service): add current commit at build time to /info (#139)
- Loading branch information
1 parent
3f00cf0
commit d113d4c
Showing
3 changed files
with
24 additions
and
0 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; | ||
|
||
fn main() { | ||
// Get the latest commit hash | ||
let output = Command::new("git") | ||
.args(["rev-parse", "HEAD"]) | ||
.output() | ||
.expect("Failed to execute git"); | ||
|
||
let git_hash = String::from_utf8(output.stdout).expect("Invalid UTF-8 sequence"); | ||
let git_hash = git_hash.trim(); | ||
|
||
// Write the commit hash to an environment variable | ||
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", git_hash); | ||
|
||
// Re-run build.rs if .git/HEAD changes | ||
println!("cargo:rerun-if-changed=.git/HEAD"); | ||
println!("cargo:rerun-if-changed=.git/refs/heads"); | ||
} |
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