feat: shorten DIDs for patches and pushes in broker

This is broken, because the shortened whom is stored, rather than the
DID and alias separately.
This commit is contained in:
Lars Wirzenius
2026-08-26 16:13:34 +03:00
parent c051e711a8
commit 71360e526f
3 changed files with 36 additions and 12 deletions
+17 -2
View File
@@ -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("<no alias>".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())),
+18 -10
View File
@@ -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("<commit author not known>")),
),
.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("<patch author not known>")),
),
.with_child(who),
}
}
@@ -774,6 +767,21 @@ fn oid_element(oid: impl Into<String>) -> 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 {
"<unknown DID>".to_string()
};
Element::span().with_class("who").with_text(did)
}
struct ReportPage {
page: HtmlPage,
}
+1
View File
@@ -87,6 +87,7 @@ span.finished {
span.who {
font-family: monospace;
font-size: 80%;
}
table {