diff options
Diffstat (limited to 'src/report.rs')
-rw-r--r-- | src/report.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/report.rs b/src/report.rs index 0538760..297195d 100644 --- a/src/report.rs +++ b/src/report.rs @@ -3,6 +3,8 @@ use std::collections::HashSet; use std::io::Write; use std::iter::FromIterator; +const COMMIT_DIGITS: usize = 7; + #[derive(Debug, Default)] pub struct Reporter { results: Vec<SuiteMeasurements>, @@ -109,6 +111,7 @@ impl Reporter { .enumerate() .map(|(i, _)| format!("step {}", i)) .collect(); + headings.insert(0, "Commit".to_string()); headings.insert(0, "Version".to_string()); for h in headings.iter() { write!(f, "| {}", h)?; @@ -129,7 +132,8 @@ impl Reporter { r: &SuiteMeasurements, durations: &[u128], ) -> Result<(), std::io::Error> { - write!(f, "| {}", r.obnam_version())?; + write!(f, "| {}", pretty_version(r.obnam_version()))?; + write!(f, "| {}", pretty_commit(r.obnam_commit()))?; for ms in durations.iter() { write!(f, "| {}", ms)?; } @@ -162,3 +166,19 @@ impl Reporter { .filter(move |r| r.hostname() == hostname) } } + +fn pretty_version(v: &str) -> String { + if let Some(v) = v.strip_prefix("obnam-backup ") { + v.to_string() + } else { + v.to_string() + } +} + +fn pretty_commit(c: Option<&str>) -> String { + if let Some(c) = c { + c[..COMMIT_DIGITS].to_string() + } else { + "".to_string() + } +} |