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

Function build

atomic-cli/tests/it/git_import_tracked_vault_regression.rs:68–89  ·  view source on GitHub ↗
(git: &GitRepository, files: &[(&str, &str)])

Source from the content-addressed store, hash-verified

66
67fn write_tree(git: &GitRepository, files: &[(&str, &str)]) -> git2::Oid {
68 fn build(git: &GitRepository, files: &[(&str, &str)]) -> git2::Oid {
69 let mut builder = git.treebuilder(None).unwrap();
70 let mut children: BTreeMap<String, Vec<(&str, &str)>> = BTreeMap::new();
71 for (path, content) in files {
72 if let Some((head, rest)) = path.split_once('/') {
73 children
74 .entry(head.to_string())
75 .or_default()
76 .push((rest, content));
77 } else {
78 builder
79 .insert(path, git.blob(content.as_bytes()).unwrap(), 0o100644)
80 .unwrap();
81 }
82 }
83 for (name, nested) in children {
84 builder
85 .insert(&name, build(git, &nested), 0o040000)
86 .unwrap();
87 }
88 builder.write().unwrap()
89 }
90 build(git, files)
91}
92

Calls 5

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

Tested by

no test coverage detected