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

Method format_oneline

atomic-cli/src/commands/log/command.rs:360–404  ·  view source on GitHub ↗

Format entries for oneline output. # Arguments `entries` - History entries to format `hash_length` - Number of hash characters to display # Returns Formatted output string.

(&self, entries: &[HistoryEntry], hash_length: usize)

Source from the content-addressed store, hash-verified

358 ///
359 /// Formatted output string.
360 pub(crate) fn format_oneline(&self, entries: &[HistoryEntry], hash_length: usize) -> String {
361 let mut output = String::new();
362
363 // Calculate max author width for alignment
364 let max_author_width = entries
365 .iter()
366 .filter_map(|e| e.authors())
367 .filter_map(|authors| authors.first())
368 .map(|a| a.name.len())
369 .max()
370 .unwrap_or(10)
371 .min(20); // Cap at 20 characters
372
373 for entry in entries {
374 let hash_str = format_hash_with_length(&entry.hash, hash_length);
375
376 let date_str = entry
377 .timestamp()
378 .map(|ts| ts.format("%Y-%m-%d").to_string())
379 .unwrap_or_else(|| " ".to_string());
380
381 let author_name = entry
382 .authors()
383 .and_then(|authors| authors.first())
384 .map(|a| truncate_string(&a.name, max_author_width))
385 .unwrap_or_else(|| "(unknown)".to_string());
386
387 let message = entry.message().unwrap_or("(no message)");
388 let first_line = message.lines().next().unwrap_or(message);
389
390 let tagged_marker = if entry.is_tagged { "*" } else { " " };
391
392 output.push_str(&format!(
393 "{}{} {} {:width$} {}\n",
394 style_hash(&hash_str),
395 hint(tagged_marker),
396 style_timestamp(&date_str),
397 style_author(&author_name),
398 first_line,
399 width = max_author_width
400 ));
401 }
402
403 output
404 }
405
406 /// Format entries for JSON output.
407 ///

Calls 10

format_hash_with_lengthFunction · 0.85
truncate_stringFunction · 0.70
iterMethod · 0.45
authorsMethod · 0.45
lenMethod · 0.45
timestampMethod · 0.45
formatMethod · 0.45
messageMethod · 0.45
nextMethod · 0.45
linesMethod · 0.45