diff --git a/src/clone.rs b/src/clone.rs index 281ae7b9fae1bfa5de05bf4c73579655e1bd1008..70749952803668e31ee6a3ab2a565bed02fc8cc1 100644 --- a/src/clone.rs +++ b/src/clone.rs @@ -4,8 +4,10 @@ use std::process::exit; use colored::Colorize; use crate::configt; +use crate::create_hooks; use crate::init; use crate::push; +use crate::remote; fn check_remote_dir(url: &PathBuf, adress: &str) { if !push::check_dir_exist(url, adress) { @@ -37,7 +39,10 @@ fn check_remote_dir(url: &PathBuf, adress: &str) { /// Create a push the tar achive on the selected remote path /// # Arguments /// - `remote`: The name of a remote -pub fn clone(path: &str) -> () { +/// - `hooks`: a bolean indicating whether or not to use hooks +/// - `compression`: The compression that will be used when creating an archive +/// - `mode`: The mode used for checkout +pub fn clone(path: &str, hooks: bool, compression: &str, mode: &str) -> () { let (adress, url) = push::split_path(path); let (borg_path, _) = init::get_borg_folder(); if borg_path.is_dir() { @@ -49,6 +54,16 @@ pub fn clone(path: &str) -> () { push::copy_file(&borg_folder, &url, &adress, "pull"); let name = url.file_name().unwrap().to_str().unwrap(); configt::create_named_local_config(name); + let pf = url.parent().unwrap().to_path_buf(); + let full_url = if adress != "file" { + format!("{}:{}", &adress, &pf.display()) + } else { + url.to_str().unwrap().to_owned() + }; + remote::update_config("origin", &full_url, false); let gitignore = init::get_gitignore_file(); init::update_gitignore(&gitignore); + if hooks { + create_hooks::create_hooks(compression, mode); + } }