Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
feat: show who made patch/commit CI is run for
Lars Wirzenius committed 2 years ago
commit 1c64e2eb04f16075cedc20eb83364e491ec14dff
parent c0c48fd3c09fc0b54b0482afb296f0255003ee2d
7 files changed +51 -12
modified src/adapter.rs
@@ -196,6 +196,7 @@ mod test {
            Whence::branch(
                "main",
                Oid::try_from("ff3099ba5de28d954c41d0b5a84316f943794ea4").unwrap(),
+
                "J. Random Hacker <random@example.com>",
            ),
            "2024-02-29T12:58:12+02:00".into(),
        )
modified src/bin/pagegen.rs
@@ -24,6 +24,7 @@ fn main() -> Result<(), PageError> {
        Whence::branch(
            "master",
            Oid::from_str("a48081f2717f069d456ec09f31d9e639b232dbed").unwrap(),
+
            "J. Random Hacker <jrh@example.com>",
        ),
        "2024-02-27T18:29:25+02:00".into(),
    );
@@ -42,6 +43,7 @@ fn main() -> Result<(), PageError> {
        Whence::patch(
            Oid::from_str("60abd513e0fb858c0dfe95ad6c4aaeace9c25d60").unwrap(),
            Oid::from_str("091f7b7e986d05381718e2aeed2497c55dd0179a").unwrap(),
+
            "Helpful Person <helpful@example.com>",
        ),
        "2024-02-27T18:29:09+02:00".into(),
    );
@@ -58,6 +60,7 @@ fn main() -> Result<(), PageError> {
        Whence::branch(
            "master",
            Oid::from_str("79469d57841632ec4c0041f564e0b2b024abe7ec").unwrap(),
+
            "J. Random Hacker <random@example.com>",
        ),
        "2024-02-27T18:29:25+02:00".into(),
    );
modified src/broker.rs
@@ -78,16 +78,18 @@ impl Broker {
                let rid = &common.repository.id;
                if let Some(adapter) = self.adapter(rid) {
                    let whence = if let Some(PushEvent {
-
                        pusher: _,
+
                        pusher,
                        before: _,
                        after,
                        branch: _,
                        commits: _,
                    }) = push
                    {
-
                        Whence::branch("push-event-has-no-branch-name", *after)
+
                        let who = pusher.to_string();
+
                        Whence::branch("push-event-has-no-branch-name", *after, &who)
                    } else if let Some(PatchEvent { action: _, patch }) = patch {
-
                        Whence::patch(patch.id, patch.after)
+
                        let who = patch.author.to_string();
+
                        Whence::patch(patch.id, patch.after, &who)
                    } else {
                        panic!("neither push not patch event");
                    };
modified src/msg.rs
@@ -439,6 +439,16 @@ pub struct Author {
    pub alias: Option<Alias>,
}

+
impl std::fmt::Display for Author {
+
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+
        write!(f, "{}", self.id)?;
+
        if let Some(alias) = &self.alias {
+
            write!(f, " ({})", alias)?;
+
        }
+
        Ok(())
+
    }
+
}
+

/// The state of a patch.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct State {
modified src/pages.rs
@@ -194,7 +194,7 @@ impl PageData {

    fn whence_as_html(whence: &Whence) -> Element {
        match whence {
-
            Whence::Branch { name, commit } => Element::new(Tag::Span)
+
            Whence::Branch { name, commit, who } => Element::new(Tag::Span)
                .with_text("branch ")
                .with_child(
                    Element::new(Tag::Code)
@@ -206,8 +206,11 @@ impl PageData {
                    Element::new(Tag::Code)
                        .with_attribute("class", "commit")
                        .with_text(&commit.to_string()),
-
                ),
-
            Whence::Patch { patch, commit } => Element::new(Tag::Span)
+
                )
+
                .with_child(Element::new(Tag::Br))
+
                .with_text("from ")
+
                .with_child(Element::new(Tag::Span).with_class("who").with_text(who)),
+
            Whence::Patch { patch, commit, who } => Element::new(Tag::Span)
                .with_text("patch ")
                .with_child(
                    Element::new(Tag::Code)
@@ -219,7 +222,10 @@ impl PageData {
                    Element::new(Tag::Code)
                        .with_attribute("class", "commit")
                        .with_text(&commit.to_string()),
-
                ),
+
                )
+
                .with_child(Element::new(Tag::Br))
+
                .with_text("from ")
+
                .with_child(Element::new(Tag::Span).with_class("who").with_text(who)),
        }
    }

modified src/radicle-ci.css
@@ -52,3 +52,7 @@ span.running {

span.finished {
}
+

+
span.who {
+
    font-family: monospace;
+
}
modified src/run.rs
@@ -111,20 +111,33 @@ impl fmt::Display for RunState {
/// Where did the commit come that CI is run for?
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub enum Whence {
-
    Branch { name: String, commit: Oid },
-
    Patch { patch: Oid, commit: Oid },
+
    Branch {
+
        name: String,
+
        commit: Oid,
+
        who: String,
+
    },
+
    Patch {
+
        patch: Oid,
+
        commit: Oid,
+
        who: String,
+
    },
}

impl Whence {
-
    pub fn branch(name: &str, commit: Oid) -> Self {
+
    pub fn branch(name: &str, commit: Oid, who: &str) -> Self {
        Self::Branch {
            name: name.into(),
            commit,
+
            who: who.into(),
        }
    }

-
    pub fn patch(patch: Oid, commit: Oid) -> Self {
-
        Self::Patch { patch, commit }
+
    pub fn patch(patch: Oid, commit: Oid, who: &str) -> Self {
+
        Self::Patch {
+
            patch,
+
            commit,
+
            who: who.into(),
+
        }
    }
}