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

Function tree

atomic-repository/src/repository/revise/replay.rs:69–100  ·  view source on GitHub ↗
(repo: &Repository, view: &str)

Source from the content-addressed store, hash-verified

67}
68
69fn tree(repo: &Repository, view: &str) -> Result<Tree, RepositoryError> {
70 let mut files = Tree::new();
71 let filter = GitAttributesFilter::for_repository(repo.root());
72 repo.materialize_view_entries::<RepositoryError>(view, |entry| {
73 if entry.conflict_marker_line.is_some() {
74 return Err(invalid(format!(
75 "cannot revise unresolved conflict at '{}'",
76 entry.path
77 )));
78 }
79 let file = File {
80 path: entry.path.clone(),
81 kind: entry.kind,
82 mode: entry.mode,
83 bytes: if entry.kind == ViewEntryKind::File {
84 filter
85 .clean(Path::new(&entry.path), &entry.content)
86 .map_err(|e| invalid(e.to_string()))?
87 .bytes
88 } else {
89 entry.content
90 },
91 };
92 if files.insert(entry.inode, file).is_some() {
93 return Err(invalid(
94 "cannot revise unresolved concurrent names for one inode",
95 ));
96 }
97 Ok(())
98 })??;
99 Ok(files)
100}
101
102fn paths(tree: &Tree) -> BTreeMap<&str, &File> {
103 tree.values()

Callers 3

verifyFunction · 0.70
planFunction · 0.70

Calls 5

invalidFunction · 0.70
rootMethod · 0.45
cloneMethod · 0.45
cleanMethod · 0.45
insertMethod · 0.45

Tested by 1