refactor: add helper function to git clone

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-01-10 17:38:05 +02:00
parent 32486e8254
commit 407fc97914
+17 -12
View File
@@ -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")?;