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

Method print_change_header

atomic-cli/src/commands/diff/helpers.rs:684–740  ·  view source on GitHub ↗

Print header information for a change diff. Displays the change hash, message, author, and timestamp before showing the actual diff content.

(
        &self,
        change: &Change,
        change_hash: &Hash,
        config: &DiffOutputConfig,
    )

Source from the content-addressed store, hash-verified

682 /// Displays the change hash, message, author, and timestamp before
683 /// showing the actual diff content.
684 pub(super) fn print_change_header(
685 &self,
686 change: &Change,
687 change_hash: &Hash,
688 config: &DiffOutputConfig,
689 ) {
690 let header = &change.hashed.header;
691 let hash_str = change_hash.to_base32();
692 let display_hash = hash_str[..DEFAULT_HASH_LENGTH.min(hash_str.len())].to_string();
693
694 // Print change identifier
695 if config.color {
696 println!("{} {}", emphasis("change"), hash(&display_hash));
697 } else {
698 println!("change {}", display_hash);
699 }
700
701 // Print author(s)
702 for author in header.authors.iter() {
703 let author_str = if let Some(ref email) = author.email {
704 format!("{} <{}>", author.name, email)
705 } else {
706 author.name.clone()
707 };
708 if config.color {
709 println!("Author: {}", info(&author_str));
710 } else {
711 println!("Author: {}", author_str);
712 }
713 }
714
715 // Print timestamp
716 let timestamp = header.timestamp.format("%Y-%m-%d %H:%M:%S %Z").to_string();
717 if config.color {
718 println!("Date: {}", info(&timestamp));
719 } else {
720 println!("Date: {}", timestamp);
721 }
722
723 // Print message
724 println!();
725 if config.color {
726 println!(" {}", emphasis(&header.message));
727 } else {
728 println!(" {}", header.message);
729 }
730
731 // Print description if present
732 if let Some(ref desc) = header.description {
733 println!();
734 for line in desc.lines() {
735 println!(" {}", line);
736 }
737 }
738
739 println!();
740 }
741

Calls 6

to_base32Method · 0.45
lenMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45
formatMethod · 0.45
linesMethod · 0.45

Tested by

no test coverage detected