-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add git commit hash and timestamp to info endpoint (#392)
* Add commit hash and timestamp * Fixed Docker build problem #392 * Fix error message and docker build. * Update README and openapi yaml. * Formatting. --------- Co-authored-by: Hendrik Eeckhaut <[email protected]>
- Loading branch information
Showing
7 changed files
with
139 additions
and
11 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,21 @@ | ||
use std::process::Command; | ||
|
||
fn main() { | ||
// Used to extract latest HEAD commit hash and timestamp for the /info endpoint | ||
let output = Command::new("git") | ||
.args(["show", "HEAD", "-s", "--format=%H,%cI"]) | ||
.output() | ||
.expect("Git command to get commit hash and timestamp should work during build process"); | ||
|
||
let output_string = | ||
String::from_utf8(output.stdout).expect("Git command should produce valid string output"); | ||
|
||
let (commit_hash, commit_timestamp) = output_string | ||
.as_str() | ||
.split_once(',') | ||
.expect("Git commit hash and timestamp string output should be comma separated"); | ||
|
||
// Pass these 2 values as env var to the program | ||
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", commit_hash); | ||
println!("cargo:rustc-env=GIT_COMMIT_TIMESTAMP={}", commit_timestamp); | ||
} |
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
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
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