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

Method format_oneline

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

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

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