Checkout out target branch on origin
This commit is contained in:
parent
555c953a91
commit
154b3d4621
|
@ -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<String, Error> {
|
||||
let mut pref = OsString::from("origin/");
|
||||
pref.push(git_ref);
|
||||
|
||||
self.checkout_ref(&pref)
|
||||
}
|
||||
|
||||
pub fn checkout_ref(&self, git_ref: &OsStr) -> Result<String, Error> {
|
||||
fs::create_dir_all(&self.root)?;
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in a new issue