Radish alpha
r
rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE
Radicle CI adapter for native CI
Radicle
Git
refactor: add helper function to git clone
Lars Wirzenius committed 2 years ago
commit 407fc9791408bf7ed37851d018138baacd19c837
parent 32486e8
1 file changed +17 -12
modified src/bin/radicle-native-ci.rs
@@ -182,6 +182,22 @@ impl<'a> Runner<'a> {
        Ok(())
    }

+
    fn git_clone(&mut self, repo_path: &Path) -> Result<(), NativeError> {
+
        debug!("cloning repository to {}", self.src.display());
+
        self.log_str("clone repository\n")?;
+
        runcmd(
+
            &mut self.run_log,
+
            &[
+
                "git",
+
                "clone",
+
                repo_path.to_str().unwrap(),
+
                self.src.to_str().unwrap(),
+
            ],
+
            Path::new("."),
+
        )?;
+
        Ok(())
+
    }
+

    /// Perform the CI run.
    fn run(&mut self) -> Result<(), NativeError> {
        self.log(format!("CI run on {}, {}\n", self.repo, self.commit))?;
@@ -195,18 +211,7 @@ impl<'a> Runner<'a> {
        let repo_path = self.storage.join(self.repo.canonical());
        debug!("repo path: {}", repo_path.display());

-
        debug!("cloning repository to {}", self.src.display());
-
        self.log_str("clone repository\n")?;
-
        runcmd(
-
            &mut self.run_log,
-
            &[
-
                "git",
-
                "clone",
-
                repo_path.to_str().unwrap(),
-
                self.src.to_str().unwrap(),
-
            ],
-
            Path::new("."),
-
        )?;
+
        self.git_clone(&repo_path)?;

        debug!("checking out commit {}", self.commit);
        self.log_str("check out commit\n")?;