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

+
    fn git_checkout(&mut self) -> Result<(), NativeError> {
+
        debug!("checking out commit {}", self.commit);
+
        self.log_str("check out commit\n")?;
+
        runcmd(
+
            &mut self.run_log,
+
            &["git", "checkout", &self.commit.to_string()],
+
            &self.src,
+
        )?;
+
        Ok(())
+
    }
+

    /// Perform the CI run.
    fn run(&mut self) -> Result<(), NativeError> {
        self.log(format!("CI run on {}, {}\n", self.repo, self.commit))?;
@@ -212,14 +223,7 @@ impl<'a> Runner<'a> {
        debug!("repo path: {}", repo_path.display());

        self.git_clone(&repo_path)?;
-

-
        debug!("checking out commit {}", self.commit);
-
        self.log_str("check out commit\n")?;
-
        runcmd(
-
            &mut self.run_log,
-
            &["git", "checkout", &self.commit.to_string()],
-
            &self.src,
-
        )?;
+
        self.git_checkout()?;

        let runspec = RunSpec::from_file(&self.src.join(RUNSPEC_PATH))?;
        self.log(format!("CI run spec: {:#?}\n", runspec))?;