Radish alpha
r
rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE
Radicle CI adapter for native CI
Radicle
Git
fix: inline variables into format strings
Lars Wirzenius committed 10 months ago
commit 21861f78bf663efa272675e375ddb9edef544c65
parent 65c1b60
4 files changed +20 -21
modified src/bin/radicle-native-ci.rs
@@ -34,10 +34,10 @@ fn main() {
            }
        }
        Err(e) => {
-
            eprintln!("ERROR: {}", e);
+
            eprintln!("ERROR: {e}");
            let mut e = e.source();
            while let Some(source) = e {
-
                eprintln!("caused by: {}", source);
+
                eprintln!("caused by: {source}");
                e = source.source();
            }
            EXIT_ERROR
modified src/engine.rs
@@ -62,7 +62,7 @@ impl Engine {
        let req = match self.setup() {
            Ok(req) => req,
            Err(e) => {
-
                self.adminlog.writeln(&format!("Error setting up: {}", e))?;
+
                self.adminlog.writeln(&format!("Error setting up: {e}"))?;
                return Err(e);
            }
        };
@@ -90,7 +90,7 @@ impl Engine {
                        // went wrong in that is not due to the repository
                        // under test. So we don't put it in the run log,
                        // but the admin log and return it to the caller.
-
                        self.adminlog.writeln(&format!("Error running CI: {}", e))?;
+
                        self.adminlog.writeln(&format!("Error running CI: {e}"))?;
                        return Err(e);
                    }
                }
@@ -121,7 +121,7 @@ impl Engine {
                        // went wrong in that is not due to the repository
                        // under test. So we don't put it in the run log,
                        // but the admin log and return it to the caller.
-
                        self.adminlog.writeln(&format!("Error running CI: {}", e))?;
+
                        self.adminlog.writeln(&format!("Error running CI: {e}"))?;
                        return Err(e);
                    }
                }
@@ -135,8 +135,7 @@ impl Engine {
        }

        if let Err(e) = self.finish() {
-
            self.adminlog
-
                .writeln(&format!("Error finishing up: {}", e))?;
+
            self.adminlog.writeln(&format!("Error finishing up: {e}"))?;
            return Err(e);
        }

@@ -152,7 +151,7 @@ impl Engine {

        // Read request and log it.
        let req = read_request()?;
-
        self.adminlog.writeln(&format!("request: {:#?}", req))?;
+
        self.adminlog.writeln(&format!("request: {req:#?}"))?;

        Ok(req)
    }
@@ -189,7 +188,7 @@ impl Engine {
        // Pick a run id and create a directory for files related to
        // the run.
        let (run_id, run_dir) = mkdir_run(&self.config)?;
-
        let run_id = RunId::from(format!("{}", run_id).as_str());
+
        let run_id = RunId::from(format!("{run_id}").as_str());

        // Set the file where the run info should be written, now that
        // we have the run directory.
@@ -204,9 +203,9 @@ impl Engine {
        // Write response to indicate run has been triggered.
        if let Some(url) = &self.config.base_url {
            let url = if url.ends_with('/') {
-
                format!("{url}{}/log.html", run_id)
+
                format!("{url}{run_id}/log.html")
            } else {
-
                format!("{url}/{}/log.html", run_id)
+
                format!("{url}/{run_id}/log.html")
            };
            write_triggered(&run_id, Some(&url))?;
        } else {
modified src/runlog.rs
@@ -79,7 +79,7 @@ impl RunLog {
    }

    pub fn runspec_error(&mut self, e: &RunSpecError) {
-
        self.runspec_error = Some(format!("{}", e));
+
        self.runspec_error = Some(format!("{e}"));
    }

    pub fn started(&mut self, ts: SystemTime) {
@@ -228,7 +228,7 @@ impl RunLog {
        doc.push_to_body(toc.as_html());
        doc.push_to_body(body);

-
        let html = format!("{}", doc);
+
        let html = format!("{doc}");
        std::fs::write(&self.filename, html.as_bytes())
            .map_err(|e| RunLogError::Write(self.filename.clone(), e))?;

@@ -289,7 +289,7 @@ impl Command {
        for arg in self.argv.iter() {
            ul.push_child(
                Element::new(Tag::Li)
-
                    .with_child(Element::new(Tag::Code).with_text(&format!("{:?}", arg))),
+
                    .with_child(Element::new(Tag::Code).with_text(&format!("{arg:?}"))),
            );
        }
        body.push_child(ul);
modified tests/integration.rs
@@ -441,9 +441,9 @@ impl Git {
        let exit = output.status.code().unwrap();
        let stdout = String::from_utf8_lossy(&output.stdout).to_string();
        let stderr = String::from_utf8_lossy(&output.stderr).to_string();
-
        println!("  exit: {}", exit);
-
        println!("  stdout: {:?}", stdout);
-
        println!("  stderr: {:?}", stderr);
+
        println!("  exit: {exit}");
+
        println!("  stdout: {stdout:?}");
+
        println!("  stderr: {stderr:?}");

        assert_eq!(exit, 0);
        Ok(stdout)
@@ -498,9 +498,9 @@ impl Rad {
        let exit = output.status.code().unwrap();
        let stdout = String::from_utf8_lossy(&output.stdout).to_string();
        let stderr = String::from_utf8_lossy(&output.stderr).to_string();
-
        println!("  exit: {}", exit);
-
        println!("  stdout: {:?}", stdout);
-
        println!("  stderr: {:?}", stderr);
+
        println!("  exit: {exit}");
+
        println!("  stdout: {stdout:?}");
+
        println!("  stderr: {stderr:?}");

        assert_eq!(exit, 0);
        Ok(stdout)
@@ -729,7 +729,7 @@ fn happy_path_with_log_url() -> TestResult {
    result.assert_got_success();

    let run_id = result.run_id().unwrap();
-
    let expected = format!("https://ci.radicle.liw.fi/{}/log.html", run_id);
+
    let expected = format!("https://ci.radicle.liw.fi/{run_id}/log.html");
    result.assert_url_is(&expected);
    Ok(())
}