From 407fc9791408bf7ed37851d018138baacd19c837 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 5 Jan 2024 18:52:29 +0200 Subject: [PATCH] refactor: add helper function to git clone Signed-off-by: Lars Wirzenius --- src/bin/radicle-native-ci.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/bin/radicle-native-ci.rs b/src/bin/radicle-native-ci.rs index 8cbd930..c9f6720 100644 --- a/src/bin/radicle-native-ci.rs +++ b/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")?;