diff --git a/src/refractr.rs b/src/refractr.rs index 7f3998e..e645abf 100644 --- a/src/refractr.rs +++ b/src/refractr.rs @@ -1,4 +1,4 @@ -use git2::{Cred, FetchOptions, PushOptions, Remote, RemoteCallbacks, Repository}; +use git2::{Cred, PushOptions, RemoteCallbacks, Repository}; use sha2::{Sha256, Digest}; use crate::common::{self, Refractr}; @@ -69,23 +69,6 @@ fn fast_forward(repo_dir: &str, branches: &Option>) -> Result<(), Er Ok(()) } -fn fetch_origin(repo: &Repository, branches: &Option>) { - let mut origin = repo.find_remote("origin").unwrap(); - let callbacks = RemoteCallbacks::new(); - let mut push_options = FetchOptions::new(); - push_options.remote_callbacks(callbacks); - - let mut refs = Vec::new(); - let strings = get_branches(&repo, &branches, true); - for branch in &strings { - refs.push(branch.as_str()); - } - - if let Err(e) = origin.download(&[] as &[&str], Some(&mut push_options)) { - eprintln!("refractr: failed to fetch origin: {}: {}", origin.url().unwrap(), e) - } -} - fn make_remotes<'a> (refractr: &Refractr, repo: &'a Repository, cfg: &ConfigFile) -> Vec { // create remotes for each "to" repo let mut remote_list = Vec::new(); @@ -142,7 +125,7 @@ fn looper(refractr: Refractr, repos: Vec) { for i in 0..repos.len() { current_ints.push(u64::from(repos[i].cfg.schedule.interval.unwrap().unsigned_abs())); }; - let mut original_ints = current_ints.clone(); + let original_ints = current_ints.clone(); ctrlc::set_handler(move || { r.store(false, Ordering::SeqCst); @@ -166,8 +149,7 @@ fn looper(refractr: Refractr, repos: Vec) { if i <= 0 { current_ints[i] = original_ints[i].clone(); common::verbose(refractr.verbose, 2, format!("Interval for {} has arrived, pulling", repos[i].cfg.from)); - fetch_origin(&repos[i].repo, &repos[i].cfg.branches); - common::verbose(refractr.verbose, 2, format!("Pushing {}", repos[i].cfg.from)); + let _ = fast_forward(&repos[i].repo.path().to_string_lossy(), &repos[i].cfg.branches); push_remotes(&refractr, &repos[i].cfg, &repos[i].repo, &repos[i].remotes); } }