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

Method format_oneline

atomic-cli/src/commands/log/command.rs:362–406  ·  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

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

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