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

Function collect_tree_entries

atomic-cli/src/commands/git/observation.rs:844–875  ·  view source on GitHub ↗
(
    repository: &GitRepository,
    tree: &git2::Tree<'_>,
    prefix: &[u8],
    entries: &mut Vec<TreeEntryObservation>,
)

Source from the content-addressed store, hash-verified

842}
843
844fn collect_tree_entries(
845 repository: &GitRepository,
846 tree: &git2::Tree<'_>,
847 prefix: &[u8],
848 entries: &mut Vec<TreeEntryObservation>,
849) -> Result<(), ObservationError> {
850 for entry in tree.iter() {
851 let mut path = prefix.to_vec();
852 if !path.is_empty() {
853 path.push(b'/');
854 }
855 path.extend_from_slice(entry.name_bytes());
856
857 if entry.kind() == Some(ObjectType::Tree) {
858 let child = repository.find_tree(entry.id()).map_err(|error| {
859 ObservationError::new(format!(
860 "cannot read Git tree {} while observing '{}': {error}",
861 entry.id(),
862 display_git_bytes(&path)
863 ))
864 })?;
865 collect_tree_entries(repository, &child, &path, entries)?;
866 } else {
867 entries.push(TreeEntryObservation {
868 path,
869 oid: entry.id(),
870 mode: entry.filemode() as u32,
871 });
872 }
873 }
874 Ok(())
875}
876
877fn observe_index(
878 repository: &GitRepository,

Callers 1

observe_head_treeFunction · 0.70

Calls 5

iterMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45
kindMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected