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

Method print_change_header

atomic-cli/src/commands/diff/helpers.rs:679–735  ·  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

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

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