From 458ae2c5be26de0936fe14d45654a11afc8fedfe Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Tue, 15 Feb 2022 07:51:44 -0800 Subject: [PATCH] performance-metrics: Add git committer date to the report Signed-off-by: Bo Chen --- performance-metrics/build.rs | 13 +++++++++++++ performance-metrics/src/main.rs | 2 ++ 2 files changed, 15 insertions(+) diff --git a/performance-metrics/build.rs b/performance-metrics/build.rs index a13f3ee01..8b3fa0b15 100644 --- a/performance-metrics/build.rs +++ b/performance-metrics/build.rs @@ -27,10 +27,23 @@ fn main() { } } + let mut git_committer_date = "".to_string(); + if let Ok(git_out) = Command::new("git") + .args(&["show", "-s", "--format=%cd"]) + .output() + { + if git_out.status.success() { + if let Ok(git_out_str) = String::from_utf8(git_out.stdout) { + git_committer_date = git_out_str; + } + } + } + // This println!() has a special behavior, as it will set the environment // variable GIT_human_readable, so that it can be reused from the binary. // Particularly, this is used from the main.rs to display the exact // version information. println!("cargo:rustc-env=GIT_HUMAN_READABLE={}", git_human_readable); println!("cargo:rustc-env=GIT_REVISION={}", git_revision); + println!("cargo:rustc-env=GIT_COMMITER_DATE={}", git_committer_date); } diff --git a/performance-metrics/src/main.rs b/performance-metrics/src/main.rs index 88f8d9c37..0909dfa5a 100644 --- a/performance-metrics/src/main.rs +++ b/performance-metrics/src/main.rs @@ -38,6 +38,7 @@ pub struct PerformanceTestResult { pub struct MetricsReport { pub git_human_readable: String, pub git_revision: String, + pub git_committer_date: String, pub date: String, pub results: Vec, } @@ -396,6 +397,7 @@ fn main() { let mut metrics_report = MetricsReport { git_human_readable: env!("GIT_HUMAN_READABLE").to_string(), git_revision: env!("GIT_REVISION").to_string(), + git_committer_date: env!("GIT_COMMITER_DATE").to_string(), date: date(), results: Vec::new(), };