about summary refs log tree commit diff
path: root/src/actions/create.rs
blob: 20dbff7e1b95354a3c36413e611f47d8387debae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::{actions::update, files::Locations, filesystem::Fs, history::RepositoryHistory};
use anyhow::Result;

use super::ActionOptions;

pub fn create(command_options: ActionOptions, fs: &mut impl Fs) -> Result<()> {
    let locations = Locations::from(&command_options);
    // FIXME: Re-add old repository deletion.
    // if locations.ka_path.exists() {
    //     fs::remove_dir_all(locations.ka_path.as_path())?;
    // }

    // fs::create_dir(&locations.ka_path)?;
    // fs::create_dir(&locations.ka_files_path)?;

    let mut index_file = fs.create_file(&locations.get_repository_index_path())?;
    let empty_history = RepositoryHistory::default();
    empty_history.write_to_file(fs, &mut index_file)?;

    update(command_options, fs)?;

    Ok(())
}