diff --git a/src/app.rs b/src/app.rs index 60c29d8..d9dddaa 100644 --- a/src/app.rs +++ b/src/app.rs @@ -735,7 +735,7 @@ pub async fn run(config: gcm::Configure) -> gcm::StandardResult { let state = AppState { // cached_country_names: common::valid_country_name(), configures: config.clone(), - repo: Arc::new(Mutex::new(Repository::open_bare( + repo: Arc::new(Mutex::new(Repository::open( config.get("GIT_REPO_LOCAL_DEST").unwrap_or(&"".to_string()), )?)), redis: redis_pool.clone(), diff --git a/src/git.rs b/src/git.rs index c0ab2da..779141d 100644 --- a/src/git.rs +++ b/src/git.rs @@ -1,16 +1,21 @@ -use std::{cell::RefCell, collections::HashMap, io::{self, Write}, path::{Path, PathBuf}}; +use std::{ + cell::RefCell, + collections::HashMap, + io::{self, Write}, + path::{Path, PathBuf}, +}; -use git2::{build::RepoBuilder, Cred, FetchOptions, Progress, RemoteCallbacks}; -use log::{info}; +use git2::{Cred, FetchOptions, Progress, RemoteCallbacks, build::RepoBuilder}; +use log::info; use crate::gcm; struct GitState { - progress: Option>, - total: usize, - current: usize, - path: Option, - newline: bool + progress: Option>, + total: usize, + current: usize, + path: Option, + newline: bool, } fn print(state: &mut GitState) { @@ -29,10 +34,11 @@ fn print(state: &mut GitState) { state.newline = true; } - info!("Resolving deltas {}/{}", - stats.indexed_deltas(), - stats.total_deltas()); - + info!( + "Resolving deltas {}/{}", + stats.indexed_deltas(), + stats.total_deltas() + ); } else { info!( "net {:3}% ({:4} kb, {:5}/{:5}) / idx {:3}% ({:5}/{:5}) \ @@ -58,40 +64,38 @@ fn print(state: &mut GitState) { } pub fn setup_git_repo(config: HashMap) -> gcm::StandardResult { - let state = RefCell::new(GitState { - progress: None, - total: 0, - current: 0, - path: None, - newline: true - }); + let state = RefCell::new(GitState { + progress: None, + total: 0, + current: 0, + path: None, + newline: true, + }); - let mut cb = RemoteCallbacks::new(); - cb.transfer_progress(|stats| { - let mut state = state.borrow_mut(); - state.progress = Some(stats.to_owned()); - print(&mut state); - true - }); + let mut cb = RemoteCallbacks::new(); + cb.transfer_progress(|stats| { + let mut state = state.borrow_mut(); + state.progress = Some(stats.to_owned()); + print(&mut state); + true + }); - cb.credentials(|_,_,_| { - Cred::userpass_plaintext( - config.get("GIT_REPO_USERNAME").unwrap_or(&"".to_string()), - config.get("GIT_REPO_PASSWORD").unwrap_or(&"".to_string()) - ) - }); + cb.credentials(|_, _, _| { + Cred::userpass_plaintext( + config.get("GIT_REPO_USERNAME").unwrap_or(&"".to_string()), + config.get("GIT_REPO_PASSWORD").unwrap_or(&"".to_string()), + ) + }); - let mut fo = FetchOptions::new(); - fo.remote_callbacks(cb); - fo.depth(1); + let mut fo = FetchOptions::new(); + fo.remote_callbacks(cb); - RepoBuilder::new() - .bare(true) - .fetch_options(fo) - .clone( - config.get("GIT_REPO_REMOTE").unwrap_or(&"".to_string()), - Path::new(config.get("GIT_REPO_LOCAL_DEST").unwrap()).into() + let _ = RepoBuilder::new().bare(false).fetch_options(fo).clone( + config.get("GIT_REPO_REMOTE").unwrap_or(&"".to_string()), + Path::new(config.get("GIT_REPO_LOCAL_DEST").unwrap()).into(), )?; - Ok(()) -} \ No newline at end of file + println!("clone completed !"); + + Ok(()) +} diff --git a/src/tx/helpers.rs b/src/tx/helpers.rs index c935bc6..233a93c 100644 --- a/src/tx/helpers.rs +++ b/src/tx/helpers.rs @@ -107,7 +107,7 @@ pub async fn setup_prebuild_tx_cache( git_repo: &str, ) -> Result<(), Box> { // import tx files - let repo = match Repository::open_bare(git_repo) { + let repo = match Repository::open(git_repo) { Ok(repo) => repo, Err(_) => return Err("cannot open repo".into()), };