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

Method format_default

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

Format entries for default 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

233 ///
234 /// Formatted output string.
235 pub(crate) fn format_default(&self, entries: &[HistoryEntry], hash_length: usize) -> String {
236 let mut output = String::new();
237
238 for (i, entry) in entries.iter().enumerate() {
239 // Add separator between entries
240 if i > 0 {
241 output.push('\n');
242 }
243
244 // Change header line with hash between === markers for easy copy-paste
245 let hash_str = format_hash_with_length(&entry.hash, hash_length);
246 let tagged_marker = if entry.is_tagged { " (tag)" } else { "" };
247 let seq_str = format!("#{}", entry.sequence);
248 output.push_str(&format!(
249 "{} === {} ==={}\n",
250 hint(&seq_str),
251 style_hash(&hash_str),
252 hint(tagged_marker)
253 ));
254
255 // Authors
256 if let Some(authors) = entry.authors() {
257 for author in authors {
258 let author_line = if let Some(ref email) = author.email {
259 format!("{} <{}>", author.name, email)
260 } else {
261 author.name.clone()
262 };
263 output.push_str(&format!("Author: {}\n", style_author(&author_line)));
264 }
265 }
266
267 // Timestamp
268 if let Some(ts) = entry.timestamp() {
269 let formatted_time = format_timestamp(&ts);
270 output.push_str(&format!("Date: {}\n", style_timestamp(&formatted_time)));
271 }
272
273 // Message
274 output.push('\n');
275 if let Some(message) = entry.message() {
276 // Indent message lines
277 for line in message.lines() {
278 output.push_str(&format!(" {}\n", line));
279 }
280 }
281
282 // Description
283 if let Some(description) = entry.description() {
284 output.push('\n');
285 for line in description.lines() {
286 output.push_str(&format!(" {}\n", line));
287 }
288 }
289 }
290
291 output
292 }

Calls 10

format_hash_with_lengthFunction · 0.85
format_timestampFunction · 0.85
iterMethod · 0.45
pushMethod · 0.45
authorsMethod · 0.45
cloneMethod · 0.45
timestampMethod · 0.45
messageMethod · 0.45
linesMethod · 0.45
descriptionMethod · 0.45