| 3132 | } |
| 3133 | |
| 3134 | fn write_git_tree(git: &GitRepository, files: &BTreeMap<String, Vec<u8>>) -> CliResult<Oid> { |
| 3135 | let mut root = GitTreeNode::default(); |
| 3136 | for (path, content) in files { |
| 3137 | let mut components = path.split('/').peekable(); |
| 3138 | let mut node = &mut root; |
| 3139 | while let Some(component) = components.next() { |
| 3140 | if components.peek().is_none() { |
| 3141 | node.files.insert(component.to_string(), content.clone()); |
| 3142 | } else { |
| 3143 | node = node.directories.entry(component.to_string()).or_default(); |
| 3144 | } |
| 3145 | } |
| 3146 | } |
| 3147 | write_git_tree_node(git, &root) |
| 3148 | } |
| 3149 | |
| 3150 | fn write_git_tree_node(git: &GitRepository, node: &GitTreeNode) -> CliResult<Oid> { |
| 3151 | let mut builder = git |