MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / build

Function build

atomic-repository/src/repository/project_tree.rs:1797–1818  ·  view source on GitHub ↗
(git: &git2::Repository, files: &[(&str, &[u8])])

Source from the content-addressed store, hash-verified

1795 paths: &[(&str, &[u8])],
1796 ) {
1797 fn build(git: &git2::Repository, files: &[(&str, &[u8])]) -> git2::Oid {
1798 let mut builder = git.treebuilder(None).unwrap();
1799 let mut directories = std::collections::BTreeMap::<&str, Vec<(&str, &[u8])>>::new();
1800 for &(path, bytes) in files {
1801 if let Some((directory, rest)) = path.split_once('/') {
1802 directories
1803 .entry(directory)
1804 .or_default()
1805 .push((rest, bytes));
1806 } else {
1807 builder
1808 .insert(path, git.blob(bytes).unwrap(), 0o100644)
1809 .unwrap();
1810 }
1811 }
1812 for (directory, children) in directories {
1813 builder
1814 .insert(directory, build(git, &children), 0o040000)
1815 .unwrap();
1816 }
1817 builder.write().unwrap()
1818 }
1819 let tree = git.find_tree(build(git, paths)).unwrap();
1820 let parents: Vec<_> = git
1821 .find_reference("refs/heads/main")

Callers 6

rootMethod · 0.70
first_parentMethod · 0.70
with_derivationMethod · 0.70
commit_treeFunction · 0.70
newMethod · 0.50
search_file_contentsFunction · 0.50

Calls 4

unwrapMethod · 0.45
pushMethod · 0.45
insertMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected