MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / format_blame

Method format_blame

atomic-core/src/change/credit.rs:399–418  ·  view source on GitHub ↗

Format for blame-style output. Returns a string like: `abc123 (alice [H] 2024-01-15) 42: let x = 1;`

(&self)

Source from the content-addressed store, hash-verified

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
421impl fmt::Display for LineCredit {

Callers 1

Calls 3

short_attributionMethod · 0.80
to_base32Method · 0.45
formatMethod · 0.45

Tested by 1