diff --git a/ofborg/src/checkout.rs b/ofborg/src/checkout.rs index 3d7c372..a3d4c62 100644 --- a/ofborg/src/checkout.rs +++ b/ofborg/src/checkout.rs @@ -5,6 +5,7 @@ use std::io::{Error,ErrorKind}; use ofborg::clone; use ofborg::clone::GitClonable; use std::ffi::OsStr; +use std::ffi::OsString; use std::process::Command; pub struct CachedCloner { @@ -73,6 +74,13 @@ impl CachedProject { } impl CachedProjectCo { + pub fn checkout_origin_ref(&self, git_ref: &OsStr) -> Result { + let mut pref = OsString::from("origin/"); + pref.push(git_ref); + + self.checkout_ref(&pref) + } + pub fn checkout_ref(&self, git_ref: &OsStr) -> Result { fs::create_dir_all(&self.root)?; diff --git a/ofborg/src/clone.rs b/ofborg/src/clone.rs index 59525cc..91aa205 100644 --- a/ofborg/src/clone.rs +++ b/ofborg/src/clone.rs @@ -132,6 +132,7 @@ pub trait GitClonable { fn checkout(&self, git_ref: &OsStr) -> Result<(), Error> { let mut lock = self.lock()?; + debug!("git checkout {:?}", git_ref); let result = Command::new("git") .arg("checkout") diff --git a/ofborg/src/tasks/build.rs b/ofborg/src/tasks/build.rs index 70507b4..ee629fe 100644 --- a/ofborg/src/tasks/build.rs +++ b/ofborg/src/tasks/build.rs @@ -62,7 +62,7 @@ impl worker::SimpleWorker for BuildWorker { None => { String::from("origin/master") } }; - let refpath = co.checkout_ref(target_branch.as_ref()).unwrap(); + let refpath = co.checkout_origin_ref(target_branch.as_ref()).unwrap(); co.fetch_pr(job.pr.number).unwrap(); if !co.commit_exists(job.pr.head_sha.as_ref()) {