set up callbacks for pulling from SSH
This commit is contained in:
parent
d7b4d072ca
commit
1c09b6a5f9
1 changed files with 20 additions and 3 deletions
|
@ -2,9 +2,9 @@ use crate::freak_out;
|
|||
use crate::common;
|
||||
use crate::config::{Config, ConfigFile};
|
||||
|
||||
use git2::{CertificateCheckStatus, Cred, PushOptions, RemoteCallbacks, Repository};
|
||||
use git2::{FetchOptions, CertificateCheckStatus, Cred, PushOptions, RemoteCallbacks, Repository};
|
||||
use git2::{Error, ErrorCode};
|
||||
use git2::build::CheckoutBuilder;
|
||||
use git2::build::{RepoBuilder, CheckoutBuilder};
|
||||
use hex;
|
||||
use sha2::{Sha256, Digest};
|
||||
use std::env;
|
||||
|
@ -238,8 +238,16 @@ impl Refractr {
|
|||
self.verbose,
|
||||
1,
|
||||
format!("Cloning repository: {}", &cfg.config.from));
|
||||
|
||||
let cb = RemoteCallbacks::new();
|
||||
let mut fo = FetchOptions::new();
|
||||
fo.download_tags(git2::AutotagOption::All);
|
||||
fo.remote_callbacks(cb);
|
||||
let mut builder = RepoBuilder::new();
|
||||
builder.fetch_options(fo);
|
||||
|
||||
let repo_dir = format!("{}/{}", &path_str, repo_name);
|
||||
let repo = match Repository::clone(&cfg.config.from, Path::new(&repo_dir)) {
|
||||
let repo = match builder.clone(&cfg.config.from, Path::new(&repo_dir)) {
|
||||
Ok(repo) => repo,
|
||||
Err(_) => {
|
||||
common::warning(format!("found existing repo at {}, attempting to use", repo_dir));
|
||||
|
@ -255,6 +263,14 @@ impl Refractr {
|
|||
};
|
||||
|
||||
let repo_fresh = Repository::open(Path::new(&repo_dir)).unwrap();
|
||||
let mut origin = repo_fresh.find_remote("origin").unwrap();
|
||||
let mut refs = Vec::new();
|
||||
let strings = self.get_refs(&cfg.config.branches);
|
||||
for branch in &strings {
|
||||
refs.push(branch.as_str());
|
||||
}
|
||||
origin.fetch(&refs, None, None).unwrap();
|
||||
|
||||
let remotes = match self.make_remotes(&repo_fresh, &cfg) {
|
||||
Ok(v) => v,
|
||||
Err(e) => return Err(e)
|
||||
|
@ -262,6 +278,7 @@ impl Refractr {
|
|||
if let Err(e) = self.push_remotes(&cfg.config, &repo, &remotes) {
|
||||
return Err(e)
|
||||
}
|
||||
|
||||
if cfg.config.schedule.enabled {
|
||||
loop_repos.push(OpenedRepository {
|
||||
repo,
|
||||
|
|
Loading…
Add table
Reference in a new issue