my dumb ass forgot i already had a fast forward function
This commit is contained in:
parent
46a5980432
commit
dc86ad15fe
1 changed files with 3 additions and 21 deletions
|
@ -1,4 +1,4 @@
|
||||||
use git2::{Cred, FetchOptions, PushOptions, Remote, RemoteCallbacks, Repository};
|
use git2::{Cred, PushOptions, RemoteCallbacks, Repository};
|
||||||
use sha2::{Sha256, Digest};
|
use sha2::{Sha256, Digest};
|
||||||
|
|
||||||
use crate::common::{self, Refractr};
|
use crate::common::{self, Refractr};
|
||||||
|
@ -69,23 +69,6 @@ fn fast_forward(repo_dir: &str, branches: &Option<Vec<String>>) -> Result<(), Er
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_origin(repo: &Repository, branches: &Option<Vec<String>>) {
|
|
||||||
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<String> {
|
fn make_remotes<'a> (refractr: &Refractr, repo: &'a Repository, cfg: &ConfigFile) -> Vec<String> {
|
||||||
// create remotes for each "to" repo
|
// create remotes for each "to" repo
|
||||||
let mut remote_list = Vec::new();
|
let mut remote_list = Vec::new();
|
||||||
|
@ -142,7 +125,7 @@ fn looper(refractr: Refractr, repos: Vec<OpenedRepository>) {
|
||||||
for i in 0..repos.len() {
|
for i in 0..repos.len() {
|
||||||
current_ints.push(u64::from(repos[i].cfg.schedule.interval.unwrap().unsigned_abs()));
|
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 || {
|
ctrlc::set_handler(move || {
|
||||||
r.store(false, Ordering::SeqCst);
|
r.store(false, Ordering::SeqCst);
|
||||||
|
@ -166,8 +149,7 @@ fn looper(refractr: Refractr, repos: Vec<OpenedRepository>) {
|
||||||
if i <= 0 {
|
if i <= 0 {
|
||||||
current_ints[i] = original_ints[i].clone();
|
current_ints[i] = original_ints[i].clone();
|
||||||
common::verbose(refractr.verbose, 2, format!("Interval for {} has arrived, pulling", repos[i].cfg.from));
|
common::verbose(refractr.verbose, 2, format!("Interval for {} has arrived, pulling", repos[i].cfg.from));
|
||||||
fetch_origin(&repos[i].repo, &repos[i].cfg.branches);
|
let _ = fast_forward(&repos[i].repo.path().to_string_lossy(), &repos[i].cfg.branches);
|
||||||
common::verbose(refractr.verbose, 2, format!("Pushing {}", repos[i].cfg.from));
|
|
||||||
push_remotes(&refractr, &repos[i].cfg, &repos[i].repo, &repos[i].remotes);
|
push_remotes(&refractr, &repos[i].cfg, &repos[i].repo, &repos[i].remotes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue