mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
performance-metrics: Produce some error messages if git commands fail
It is reasonable for these to fail as it the tool could be run outside of a git repository but by not giving any error message we cannot see issues when we expect the report to have the git details. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
ada85f68f6
commit
cac42301f8
@ -53,18 +53,30 @@ impl Default for MetricsReport {
|
||||
let mut git_human_readable = "".to_string();
|
||||
if let Ok(git_out) = Command::new("git").args(&["describe", "--dirty"]).output() {
|
||||
if git_out.status.success() {
|
||||
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
||||
git_human_readable = git_out_str.trim().to_string();
|
||||
}
|
||||
git_human_readable = String::from_utf8(git_out.stdout)
|
||||
.unwrap()
|
||||
.trim()
|
||||
.to_string();
|
||||
} else {
|
||||
eprintln!(
|
||||
"Error generating human readable git reference: {}",
|
||||
String::from_utf8(git_out.stderr).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let mut git_revision = "".to_string();
|
||||
if let Ok(git_out) = Command::new("git").args(&["rev-parse", "HEAD"]).output() {
|
||||
if git_out.status.success() {
|
||||
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
||||
git_revision = git_out_str.trim().to_string();
|
||||
}
|
||||
git_revision = String::from_utf8(git_out.stdout)
|
||||
.unwrap()
|
||||
.trim()
|
||||
.to_string();
|
||||
} else {
|
||||
eprintln!(
|
||||
"Error generating git reference: {}",
|
||||
String::from_utf8(git_out.stderr).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,9 +86,15 @@ impl Default for MetricsReport {
|
||||
.output()
|
||||
{
|
||||
if git_out.status.success() {
|
||||
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
||||
git_commit_date = git_out_str.trim().to_string();
|
||||
}
|
||||
git_commit_date = String::from_utf8(git_out.stdout)
|
||||
.unwrap()
|
||||
.trim()
|
||||
.to_string();
|
||||
} else {
|
||||
eprintln!(
|
||||
"Error generating git commit date: {}",
|
||||
String::from_utf8(git_out.stderr).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user