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

Method print_change_header

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

986 /// Displays the change hash, message, author, and timestamp before
987 /// showing the actual diff content.
988 pub(super) fn print_change_header(
989 &self,
990 change: &Change,
991 change_hash: &Hash,
992 config: &DiffOutputConfig,
993 ) {
994 let header = &change.hashed.header;
995 let hash_str = change_hash.to_base32();
996 let display_hash = hash_str[..DEFAULT_HASH_LENGTH.min(hash_str.len())].to_string();
997
998 // Print change identifier
999 if config.color {
1000 println!("{} {}", emphasis("change"), hash(&display_hash));
1001 } else {
1002 println!("change {}", display_hash);
1003 }
1004
1005 // Print author(s)
1006 for author in header.authors.iter() {
1007 let author_str = if let Some(ref email) = author.email {
1008 format!("{} <{}>", author.name, email)
1009 } else {
1010 author.name.clone()
1011 };
1012 if config.color {
1013 println!("Author: {}", info(&author_str));
1014 } else {
1015 println!("Author: {}", author_str);
1016 }
1017 }
1018
1019 // Print timestamp
1020 let timestamp = header.timestamp.format("%Y-%m-%d %H:%M:%S %Z").to_string();
1021 if config.color {
1022 println!("Date: {}", info(&timestamp));
1023 } else {
1024 println!("Date: {}", timestamp);
1025 }
1026
1027 // Print message
1028 println!();
1029 if config.color {
1030 println!(" {}", emphasis(&header.message));
1031 } else {
1032 println!(" {}", header.message);
1033 }
1034
1035 // Print description if present
1036 if let Some(ref desc) = header.description {
1037 println!();
1038 for line in desc.lines() {
1039 println!(" {}", line);
1040 }
1041 }
1042
1043 println!();
1044 }
1045

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