diff --git a/src/broker.rs b/src/broker.rs index da9accbe..651612f6 100644 --- a/src/broker.rs +++ b/src/broker.rs @@ -9,6 +9,7 @@ use std::{ time::Duration, }; +use radicle_ci_adapter::Author; use time::{OffsetDateTime, macros::format_description}; use tracing::{Level, span}; @@ -77,6 +78,20 @@ impl Broker { Ok(run) } + fn shorten_author(author: &Author) -> String { + let did = author.id.to_string(); + let alias = author + .alias + .clone() + .map(|a| a.as_str().to_string()) + .unwrap_or("".to_string()); + if let Some((_, suffix)) = did.to_string().split_at_checked(did.len() - 11) { + format!("..{suffix} ({alias})") + } else { + format!("{did} ({alias})") + } + } + fn execute_helper( &self, adapter: &Adapter, @@ -99,7 +114,7 @@ impl Broker { }), patch: None, } => { - let who = pusher.to_string(); + let who = Self::shorten_author(pusher); ( common, Whence::branch(branch, *after, Some(who.as_str())), @@ -116,7 +131,7 @@ impl Broker { .last() .ok_or(BrokerError::NoRevisions)? .clone(); - let who = patch.author.to_string(); + let who = Self::shorten_author(&patch.author); ( common, Whence::patch(patch.id, patch.after, revision, Some(who.as_str())), diff --git a/src/pages.rs b/src/pages.rs index 9983333f..7c01fcf0 100644 --- a/src/pages.rs +++ b/src/pages.rs @@ -542,6 +542,7 @@ impl PageData { } fn whence_as_html(whence: &Whence) -> Element { + let who = did_element(whence.who()); match whence { Whence::Branch { name, @@ -553,11 +554,7 @@ impl PageData { .with_text(", commit ") .with_child(oid_element(commit.to_string())) .with_child(Element::new(Tag::Br)) - .with_child( - Element::span() - .with_class("who") - .with_text(whence.who().unwrap_or("")), - ), + .with_child(who), Whence::Patch { patch, commit, @@ -584,11 +581,7 @@ impl PageData { .with_child(oid_element(commit.to_string())) .with_child(Element::new(Tag::Br)) .with_text("from ") - .with_child( - Element::new(Tag::Span) - .with_class("who") - .with_text(whence.who().unwrap_or("")), - ), + .with_child(who), } } @@ -774,6 +767,21 @@ fn oid_element(oid: impl Into) -> Element { .with_text(oid) } +fn did_element(did: Option<&str>) -> Element { + let did = if let Some(did) = did { + let did = if let Some(suffix) = did.strip_prefix("did:key:") { + suffix + } else { + did + }; + format!("DID {did}") + } else { + "".to_string() + }; + + Element::span().with_class("who").with_text(did) +} + struct ReportPage { page: HtmlPage, } diff --git a/src/radicle-ci.css b/src/radicle-ci.css index 8fb59fec..4584a750 100644 --- a/src/radicle-ci.css +++ b/src/radicle-ci.css @@ -87,6 +87,7 @@ span.finished { span.who { font-family: monospace; + font-size: 80%; } table {