| 3088 | } |
| 3089 | |
| 3090 | fn write_git_tree(git: &GitRepository, files: &BTreeMap<String, Vec<u8>>) -> CliResult<Oid> { |
| 3091 | let mut root = GitTreeNode::default(); |
| 3092 | for (path, content) in files { |
| 3093 | let mut components = path.split('/').peekable(); |
| 3094 | let mut node = &mut root; |
| 3095 | while let Some(component) = components.next() { |
| 3096 | if components.peek().is_none() { |
| 3097 | node.files.insert(component.to_string(), content.clone()); |
| 3098 | } else { |
| 3099 | node = node.directories.entry(component.to_string()).or_default(); |
| 3100 | } |
| 3101 | } |
| 3102 | } |
| 3103 | write_git_tree_node(git, &root) |
| 3104 | } |
| 3105 | |
| 3106 | fn write_git_tree_node(git: &GitRepository, node: &GitTreeNode) -> CliResult<Oid> { |
| 3107 | let mut builder = git |