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

Method format_short

atomic-cli/src/commands/change/command.rs:320–365  ·  view source on GitHub ↗

Format the change for short output.

(
        &self,
        change: &Change,
        hash: &Hash,
        sequence: Option<u64>,
    )

Source from the content-addressed store, hash-verified

318
319 /// Format the change for short output.
320 pub(crate) fn format_short(
321 &self,
322 change: &Change,
323 hash: &Hash,
324 sequence: Option<u64>,
325 ) -> String {
326 let hash_len = self.get_hash_length();
327 let hash_str = format_hash_with_length(hash, hash_len);
328
329 let date_str = change
330 .hashed
331 .header
332 .timestamp
333 .format("%Y-%m-%d")
334 .to_string();
335
336 let author_name = change
337 .hashed
338 .header
339 .authors
340 .first()
341 .map(|a| truncate_string(&a.name, 15))
342 .unwrap_or_else(|| "(unknown)".to_string());
343
344 let message = change
345 .hashed
346 .header
347 .message
348 .lines()
349 .next()
350 .unwrap_or("(no message)");
351
352 // Provenance indicator for short format
353 let _prov_indicator = if change.has_provenance() { " 🤖" } else { "" };
354
355 let seq_str = sequence.map(|s| format!(" #{}", s)).unwrap_or_default();
356
357 format!(
358 "{}{} {} {:15} {}\n",
359 style_hash(&hash_str),
360 hint(&seq_str),
361 style_timestamp(&date_str),
362 style_author(&author_name),
363 message
364 )
365 }
366
367 /// Format the change for JSON output.
368 pub(crate) fn format_json(

Callers 5

print_changeMethod · 0.45
test_format_short_basicFunction · 0.45

Calls 7

format_hash_with_lengthFunction · 0.85
truncate_stringFunction · 0.70
get_hash_lengthMethod · 0.45
formatMethod · 0.45
nextMethod · 0.45
linesMethod · 0.45
has_provenanceMethod · 0.45