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

Method format_oneline

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

341 ///
342 /// Formatted output string.
343 pub(crate) fn format_oneline(&self, entries: &[HistoryEntry], hash_length: usize) -> String {
344 let mut output = String::new();
345
346 // Calculate max author width for alignment
347 let max_author_width = entries
348 .iter()
349 .filter_map(|e| e.authors())
350 .filter_map(|authors| authors.first())
351 .map(|a| a.name.len())
352 .max()
353 .unwrap_or(10)
354 .min(20); // Cap at 20 characters
355
356 for entry in entries {
357 let hash_str = format_hash_with_length(&entry.hash, hash_length);
358
359 let date_str = entry
360 .timestamp()
361 .map(|ts| ts.format("%Y-%m-%d").to_string())
362 .unwrap_or_else(|| " ".to_string());
363
364 let author_name = entry
365 .authors()
366 .and_then(|authors| authors.first())
367 .map(|a| truncate_string(&a.name, max_author_width))
368 .unwrap_or_else(|| "(unknown)".to_string());
369
370 let message = entry.message().unwrap_or("(no message)");
371 let first_line = message.lines().next().unwrap_or(message);
372
373 let tagged_marker = if entry.is_tagged { "*" } else { " " };
374
375 output.push_str(&format!(
376 "{}{} {} {:width$} {}\n",
377 style_hash(&hash_str),
378 hint(tagged_marker),
379 style_timestamp(&date_str),
380 style_author(&author_name),
381 first_line,
382 width = max_author_width
383 ));
384 }
385
386 output
387 }
388
389 /// Format entries for JSON output.
390 ///

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