diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2023-02-28 22:54:04 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2023-02-28 22:54:04 +0200 |
commit | db131014cf9d40f526a42d14901f3c10cba27786 (patch) | |
tree | 93eb9780269578641cf1ba93cfbe9f1abcd92ff4 /src/git.rs | |
parent | 54e3aa3422ae75fc9d69ceb9d09a8cd1a3e168ec (diff) |
Git init
Diffstat (limited to 'src/git.rs')
-rw-r--r-- | src/git.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/git.rs b/src/git.rs new file mode 100644 index 0000000..bd26568 --- /dev/null +++ b/src/git.rs @@ -0,0 +1,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(()) +} |