Radish alpha
r
rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE
Radicle CI adapter for native CI
Radicle
Git
chore: update html-page dependency to version 0.2.0
Lars Wirzenius committed 2 years ago
commit ee90b919ae99cb2426d54f8fa6a551863a2198d8
parent c14b211
3 files changed +37 -27
modified Cargo.lock
@@ -683,6 +683,16 @@ dependencies = [
]

[[package]]
+
name = "html-page"
+
version = "0.2.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "dc5c97d0f1c30289fd33861d5dac9259b039b3c4e6d718a63806b04287329809"
+
dependencies = [
+
 "html-escape",
+
 "line-col",
+
]
+

+
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1163,7 +1173,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cde6587c2d47da67deaed0faf1d4bcbefdce320ef0af25ad5aba516fddf53721"
dependencies = [
-
 "html-page",
+
 "html-page 0.1.0",
 "log",
 "pretty_env_logger",
 "radicle",
@@ -1245,7 +1255,7 @@ dependencies = [
name = "radicle-native-ci"
version = "0.1.0"
dependencies = [
-
 "html-page",
+
 "html-page 0.2.0",
 "radicle",
 "radicle-ci-broker",
 "radicle-git-ext",
modified Cargo.toml
@@ -12,7 +12,7 @@ repository = "https://app.radicle.xyz/nodes/radicle.liw.fi/rad:z3qg5TKmN83afz2fj
categories = ["development-tools::build-utils"]

[dependencies]
-
html-page = "0.1.0"
+
html-page = "0.2.0"
radicle = "0.9.0"
radicle-ci-broker = "0.1.0"
radicle-git-ext = "0.7.0"
modified src/runlog.rs
@@ -108,32 +108,32 @@ impl RunLog {

        let mut doc = Document::default();

-
        doc.push_to_head(&Element::new(Tag::Title).with_text(title));
-
        doc.push_to_body(&Element::new(Tag::H1).with_text(title));
+
        doc.push_to_head(Element::new(Tag::Title).with_text(title));
+
        doc.push_to_body(Element::new(Tag::H1).with_text(title));

        let mut ul = Element::new(Tag::Ul);
        ul.push_child(
-
            &Element::new(Tag::Li)
+
            Element::new(Tag::Li)
                .with_text("Repository id: ")
                .with_child(Element::new(Tag::Code).with_text(&rid.to_string()))
                .with_text(" ")
                .with_text(repo_name),
        );
        ul.push_child(
-
            &Element::new(Tag::Li)
+
            Element::new(Tag::Li)
                .with_text("Commit: ")
                .with_child(Element::new(Tag::Code).with_text(&commit.to_string())),
        );
        if let Some(branch) = &self.branch {
            ul.push_child(
-
                &Element::new(Tag::Li)
+
                Element::new(Tag::Li)
                    .with_text("Branch: ")
                    .with_child(Element::new(Tag::Code).with_text(branch)),
            );
        }
        if let Some((patch, title)) = &self.patch {
            ul.push_child(
-
                &Element::new(Tag::Li)
+
                Element::new(Tag::Li)
                    .with_text("Patch: ")
                    .with_child(Element::new(Tag::Code).with_text(&patch.to_string()))
                    .with_text(" ")
@@ -141,22 +141,22 @@ impl RunLog {
            );
        }
        ul.push_child(
-
            &Element::new(Tag::Li)
+
            Element::new(Tag::Li)
                .with_text("Result: ")
                .with_child(Element::new(Tag::B).with_text(self.result())),
        );
-
        doc.push_to_body(&ul);
+
        doc.push_to_body(ul);

        if let Some(e) = &self.runspec_error {
            let error = Element::new(Tag::P)
                .with_text("Failed to load .radicle/native.yaml: ")
                .with_child(Element::new(Tag::Code).with_text(e));
-
            doc.push_to_body(&error);
+
            doc.push_to_body(error);
        }

        if self.timeout {
            let timeout = Element::new(Tag::P).with_text("Last command timed out");
-
            doc.push_to_body(&timeout);
+
            doc.push_to_body(timeout);
        }

        if let Some(runspec) = &self.runspec {
@@ -170,7 +170,7 @@ impl RunLog {
                    Element::new(Tag::Blockquote)
                        .with_child(Element::new(Tag::Pre).with_text(&text)),
                );
-
            doc.push_to_body(&native_yaml);
+
            doc.push_to_body(native_yaml);
        }

        let mut toc = ToC::default();
@@ -179,8 +179,8 @@ impl RunLog {
            cmd.format(&mut body, &mut toc);
        }

-
        doc.push_to_body(&toc.as_html());
-
        doc.push_to_body(&body);
+
        doc.push_to_body(toc.as_html());
+
        doc.push_to_body(body);

        let html = format!("{}", doc);
        std::fs::write(&self.filename, html.as_bytes())
@@ -217,7 +217,7 @@ impl Command {

    fn format(&self, body: &mut Element, toc: &mut ToC) {
        body.push_child(
-
            &toc.push(
+
            toc.push(
                Element::new(Tag::Span)
                    .with_text("Run: ")
                    .with_child(Element::new(Tag::Code).with_text(&self.command())),
@@ -225,7 +225,7 @@ impl Command {
        );

        body.push_child(
-
            &Element::new(Tag::Ul)
+
            Element::new(Tag::Ul)
                .with_child(
                    Element::new(Tag::Li)
                        .with_text(&format!("Started: {}", timestamp(&self.started))),
@@ -239,23 +239,23 @@ impl Command {
                ),
        );

-
        body.push_child(&Element::new(Tag::P).with_text("Command arguments:"));
+
        body.push_child(Element::new(Tag::P).with_text("Command arguments:"));
        let mut ul = Element::new(Tag::Ul);
        for arg in self.argv.iter() {
            ul.push_child(
-
                &Element::new(Tag::Li)
+
                Element::new(Tag::Li)
                    .with_child(Element::new(Tag::Code).with_text(&format!("{:?}", arg))),
            );
        }
-
        body.push_child(&ul);
+
        body.push_child(ul);

        body.push_child(
-
            &Element::new(Tag::P)
+
            Element::new(Tag::P)
                .with_text("In directory: ")
                .with_child(Element::new(Tag::Code).with_text(&format!("{}", self.cwd.display()))),
        );

-
        body.push_child(&Element::new(Tag::P).with_text(&format!("Exit code: {}", self.exit)));
+
        body.push_child(Element::new(Tag::P).with_text(&format!("Exit code: {}", self.exit)));

        self.output(body, "Stdout:", &self.stdout);
        self.output(body, "Stderr:", &self.stderr);
@@ -263,9 +263,9 @@ impl Command {

    fn output(&self, body: &mut Element, stream: &str, data: &[u8]) {
        if !data.is_empty() {
-
            body.push_child(&Element::new(Tag::P).with_text(stream));
+
            body.push_child(Element::new(Tag::P).with_text(stream));
            body.push_child(
-
                &Element::new(Tag::Blockquote)
+
                Element::new(Tag::Blockquote)
                    .with_child(Element::new(Tag::Pre).with_text(&String::from_utf8_lossy(data))),
            );
        }
@@ -303,9 +303,9 @@ impl ToC {
                    .with_attribute("href", &format!("#{anchor}"))
                    .with_child(content.clone()),
            );
-
            list.push_child(&entry);
+
            list.push_child(entry);
        }
-
        toc.push_child(&list);
+
        toc.push_child(list);
        toc
    }
}