Format for blame-style output. Returns a string like: `abc123 (alice [H] 2024-01-15) 42: let x = 1;`
(&self)
| 397 | /// Returns a string like: |
| 398 | /// `abc123 (alice [H] 2024-01-15) 42: let x = 1;` |
| 399 | pub fn format_blame(&self) -> String { |
| 400 | let hash_short = &self.credit.change_hash.to_base32()[..8]; |
| 401 | let date = self.credit.timestamp.format("%Y-%m-%d"); |
| 402 | let attribution = self.credit.short_attribution(); |
| 403 | |
| 404 | match &self.content { |
| 405 | Some(content) => { |
| 406 | format!( |
| 407 | "{} ({} {}) {:>4}: {}", |
| 408 | hash_short, attribution, date, self.line_number, content |
| 409 | ) |
| 410 | } |
| 411 | None => { |
| 412 | format!( |
| 413 | "{} ({} {}) {:>4}:", |
| 414 | hash_short, attribution, date, self.line_number |
| 415 | ) |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | impl fmt::Display for LineCredit { |