summaryrefslogtreecommitdiff
path: root/src/git.rs
blob: bd265683fd74d24a81d3cedac0467e1561e7e781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::ShackleError;

use git2::{Repository, RepositoryInitOptions};
use std::path::PathBuf;

pub fn init(repo_name: &str) -> Result<(), ShackleError> {
    let mut path = PathBuf::from("git");
    path.push(repo_name);
    path.set_extension("git");

    Repository::init_opts(
        path,
        &RepositoryInitOptions::new()
            .bare(true)
            .mkdir(true)
            .no_reinit(true),
    )?;
    Ok(())
}