Skip to content
Snippets Groups Projects
Verified Commit 13c70c37 authored by nfontrod's avatar nfontrod
Browse files

src/clone.rs: add hooks compression and mode parameters + add a remote...

src/clone.rs: add hooks compression and mode parameters + add a remote containing the pas used to pull the repoistory
parent e6099001
No related branches found
No related tags found
No related merge requests found
...@@ -4,8 +4,10 @@ use std::process::exit; ...@@ -4,8 +4,10 @@ use std::process::exit;
use colored::Colorize; use colored::Colorize;
use crate::configt; use crate::configt;
use crate::create_hooks;
use crate::init; use crate::init;
use crate::push; use crate::push;
use crate::remote;
fn check_remote_dir(url: &PathBuf, adress: &str) { fn check_remote_dir(url: &PathBuf, adress: &str) {
if !push::check_dir_exist(url, adress) { if !push::check_dir_exist(url, adress) {
...@@ -37,7 +39,10 @@ fn check_remote_dir(url: &PathBuf, adress: &str) { ...@@ -37,7 +39,10 @@ fn check_remote_dir(url: &PathBuf, adress: &str) {
/// Create a push the tar achive on the selected remote path /// Create a push the tar achive on the selected remote path
/// # Arguments /// # Arguments
/// - `remote`: The name of a remote /// - `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 (adress, url) = push::split_path(path);
let (borg_path, _) = init::get_borg_folder(); let (borg_path, _) = init::get_borg_folder();
if borg_path.is_dir() { if borg_path.is_dir() {
...@@ -49,6 +54,16 @@ pub fn clone(path: &str) -> () { ...@@ -49,6 +54,16 @@ pub fn clone(path: &str) -> () {
push::copy_file(&borg_folder, &url, &adress, "pull"); push::copy_file(&borg_folder, &url, &adress, "pull");
let name = url.file_name().unwrap().to_str().unwrap(); let name = url.file_name().unwrap().to_str().unwrap();
configt::create_named_local_config(name); 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(); let gitignore = init::get_gitignore_file();
init::update_gitignore(&gitignore); init::update_gitignore(&gitignore);
if hooks {
create_hooks::create_hooks(compression, mode);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment