pub fn fetch(config: &Config, root_path: &String) -> Result<(), Error> {
    match &config.hooks {
        Some(hooks) => {
            let destination_path: PathBuf = git_hooked_path(&root_path, None)?;
            let destination_path_state: PathResult = visit_path(&destination_path)?;

            match destination_path_state {
                ExistingFile | ExistingLink | InvalidLink => {
                    bail!("git_hooked destination path already exists")
                }

                Unknown => bail!("git_hooked destination path unknown"),
                NonExisting => {
                    std::fs::create_dir(&destination_path);

                    hooks
                        .into_iter()
                        .try_for_each(|hook: &Hook| fetch_hook(&root_path, &hook))?;
                }
                ExistingDir => {
                    hooks
                        .into_iter()
                        .try_for_each(|hook: &Hook| fetch_hook(&root_path, &hook))?;
                }
            }
        }
        None => {
            error!("No hooks defined in provide configuration file");
        }
    }

    Ok(())
}
// NOTE: copy over existing symlinks to the git_hooks folder
copy over existing symlinks to the git_hooks folder
copy over existing symlinks to the git_hooks folder
pub fn fetch(config: &Config, root_path: &String) -> Result<(), Error> {
    match &config.hooks {
        Some(hooks) => {
            let destination_path: PathBuf = git_hooked_path(&root_path, None)?;
            let destination_path_state: PathResult = visit_path(&destination_path)?;
            match destination_path_state {
                ExistingFile | ExistingLink | InvalidLink => {
                    bail!("git_hooked destination path already exists")
                }
                Unknown => bail!("git_hooked destination path unknown"),
                NonExisting => {
                    std::fs::create_dir(&destination_path);
                    hooks
                        .into_iter()
                        .try_for_each(|hook: &Hook| fetch_hook(&root_path, &hook))?;
                }
                ExistingDir => {
                    hooks
                        .into_iter()
                        .try_for_each(|hook: &Hook| fetch_hook(&root_path, &hook))?;
                }
            }
        }
        None => {
            error!("No hooks defined in provide configuration file");
        }
    }
    Ok(())
}
pub fn fetch ( config : & Config , root_path : & String ) -> Result < ( ) , Error > { match & config . hooks { Some ( hooks ) => { let destination_path : PathBuf = git_hooked_path ( & root_path , None ) ? ; let destination_path_state : PathResult = visit_path ( & destination_path ) ? ; match destination_path_state { ExistingFile | ExistingLink | InvalidLink => { bail ! ( " " ) } Unknown => bail ! ( " " ) , NonExisting => { std :: fs :: create_dir ( & destination_path ) ; hooks . into_iter ( ) . try_for_each ( | hook : & Hook | fetch_hook ( & root_path , & hook ) ) ? ; } ExistingDir => { hooks . into_iter ( ) . try_for_each ( | hook : & Hook | fetch_hook ( & root_path , & hook ) ) ? ; } } } None => { error ! ( " " ) ; } } Ok ( ( ) ) }
NOTE: copy over existing symlinks to the git_hooks folder
NOTE : copy over existing symlinks to the git_hooks folder
config
&Config
root_path
&String