Skip to content
Snippets Groups Projects
Commit f542474a authored by nfontrod's avatar nfontrod
Browse files

src/init.rs: creation of init_and_hook function

parent 02bb8285
No related branches found
No related tags found
No related merge requests found
use std::path::PathBuf;
use std::process::{exit, Command};
use crate::create_hooks;
/// Function used to get borg repository folder and results repository only if
/// the project is inside a git repository
......@@ -40,7 +41,7 @@ pub fn get_borg_folder() -> (PathBuf, PathBuf) {
}
/// Creation of a borg repository in the same directory as the .git repository
pub fn init_repository() {
fn init_repository() {
let (borg_path, _) = get_borg_folder();
let output = Command::new("borg")
.arg("init")
......@@ -65,3 +66,16 @@ pub fn init_repository() {
}
}
}
/// Creation of a borg repository and creation of hooks if needed inside `.git/hooks`
/// folder
/// # Arguments:
/// * `hooks`: a boolean indicating wether or not to create hooks
/// * `compression`: The compression used automatically after each commit. This parameter is only used if hooks is true.
pub fn init_and_hook(hooks: bool, compression: &str) {
init_repository();
if hooks {
create_hooks::create_hooks(compression);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment