| 9 | }; |
| 10 | |
| 11 | pub(super) fn render_log_human(log: &OperationLogDto) -> String { |
| 12 | let mut output = String::new(); |
| 13 | writeln!(output, "Operation log").unwrap(); |
| 14 | writeln!(output, "Scope: {}", format_scope(&log.scope)).unwrap(); |
| 15 | match &log.head_state { |
| 16 | OperationHeadStateDto::Empty => { |
| 17 | writeln!(output, "Head state: empty").unwrap(); |
| 18 | } |
| 19 | OperationHeadStateDto::Single { head } => { |
| 20 | writeln!(output, "Head state: single").unwrap(); |
| 21 | writeln!(output, " HEAD {head}").unwrap(); |
| 22 | } |
| 23 | OperationHeadStateDto::Diverged { heads } => { |
| 24 | writeln!(output, "Head state: DIVERGED ({} heads)", heads.len()).unwrap(); |
| 25 | for head in heads { |
| 26 | writeln!(output, " HEAD {head}").unwrap(); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | writeln!(output, "Operations:").unwrap(); |
| 32 | if log.entries.is_empty() { |
| 33 | writeln!(output, " none").unwrap(); |
| 34 | return output; |
| 35 | } |
| 36 | |
| 37 | for entry in &log.entries { |
| 38 | let marker = if entry.is_head { "HEAD" } else { " " }; |
| 39 | writeln!(output, " {marker} {}", entry.id).unwrap(); |
| 40 | writeln!(output, " encoding_version: {}", entry.encoding_version).unwrap(); |
| 41 | writeln!(output, " kind: {}", entry.kind).unwrap(); |
| 42 | writeln!( |
| 43 | output, |
| 44 | " relation: {}", |
| 45 | format_relation(entry.relation.as_ref()) |
| 46 | ) |
| 47 | .unwrap(); |
| 48 | writeln!(output, " scope: {}", format_scope(&entry.scope)).unwrap(); |
| 49 | write_string_list(&mut output, 4, "parents", &entry.parents); |
| 50 | writeln!(output, " actor: {}", format_actor(&entry.actor)).unwrap(); |
| 51 | write_timestamp( |
| 52 | &mut output, |
| 53 | 4, |
| 54 | entry.timestamp_ms, |
| 55 | entry.timestamp_utc.as_deref(), |
| 56 | ); |
| 57 | writeln!(output, " verification: {}", entry.verification).unwrap(); |
| 58 | } |
| 59 | output |
| 60 | } |
| 61 | |
| 62 | pub(super) fn render_details_human(details: &OperationDetailsDto) -> String { |
| 63 | let mut output = String::new(); |