MCPcopy Index your code
hub / github.com/emwalker/digraph / init

Method init

backend/src/git/core/mod.rs:67–87  ·  view source on GitHub ↗

https://github.com/rust-lang/git2-rs/blob/master/examples/init.rs#L94

(path: &PathBuf)

Source from the content-addressed store, hash-verified

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)?)

Callers

nothing calls this directly

Calls 3

initFunction · 0.85
commitMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected