https://github.com/rust-lang/git2-rs/blob/master/examples/init.rs#L94
(path: &PathBuf)
| 65 | |
| 66 | // https://github.com/rust-lang/git2-rs/blob/master/examples/init.rs#L94 |
| 67 | fn init(path: &PathBuf) -> Result<Self> { |
| 68 | let repo = git2::Repository::init(path)?; |
| 69 | |
| 70 | log::info!("repo not found, initializing: {:?}", path); |
| 71 | let sig = git2::Signature::now("digraph-bot", "noreply@digraph.app")?; |
| 72 | |
| 73 | let tree_id = { |
| 74 | let mut index = repo.index()?; |
| 75 | index.add_all(["*"].iter(), git2::IndexAddOption::DEFAULT, None)?; |
| 76 | index.write_tree()? |
| 77 | }; |
| 78 | |
| 79 | let tree = repo.find_tree(tree_id)?; |
| 80 | repo.commit(Some("HEAD"), &sig, &sig, "Initial commit", &tree, &[])?; |
| 81 | drop(tree); |
| 82 | |
| 83 | Ok(Repo { |
| 84 | inner: repo, |
| 85 | path: path.to_owned(), |
| 86 | }) |
| 87 | } |
| 88 | |
| 89 | pub fn add_blob(&self, ser: &[u8]) -> Result<git2::Oid> { |
| 90 | Ok(self.inner.odb()?.write(git2::ObjectType::Blob, ser)?) |