Skip to content

Commit

Permalink
Add get_children_blob fn
Browse files Browse the repository at this point in the history
  • Loading branch information
hateofhades committed Dec 26, 2024
1 parent e5395a2 commit d0fcfc8
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src-tauri/src/git/git_tree.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use crate::errors::git_object_error::GitObjectError;

use super::object::{GitObject, Header};
use super::{
git_blob::GitBlob,
git_project::GitProject,
object::{GitObject, Header},
};

#[derive(Debug, Clone, PartialEq)]
pub enum GitTreeMode {
Expand Down Expand Up @@ -138,6 +142,30 @@ impl GitTree {
.filter(|entry| entry.mode != GitTreeMode::Tree)
.collect()
}

/**
* Retrieve all blobs entries in the GitTree
* and from the trees in the GitTree
*
* Returns the blob entries
*/
pub fn get_children_blobs(&self, project: &GitProject) -> Vec<GitBlob> {
let mut objects: Vec<GitBlob> = Vec::new();

let _ = self.get_trees().iter().map(|tree| {
let tree_obj = GitTree::from_hash(project, &tree.hash).unwrap_or_default();

let _ = tree_obj.get_blobs().iter().map(|blob| {
let obj = GitBlob::from_hash(project, &blob.hash);

Check warning on line 159 in src-tauri/src/git/git_tree.rs

View check run for this annotation

Codecov / codecov/patch

src-tauri/src/git/git_tree.rs#L152-L159

Added lines #L152 - L159 were not covered by tests

if let Ok(obj) = obj {
objects.push(obj);
}
});
});

objects
}

Check warning on line 168 in src-tauri/src/git/git_tree.rs

View check run for this annotation

Codecov / codecov/patch

src-tauri/src/git/git_tree.rs#L161-L168

Added lines #L161 - L168 were not covered by tests
}

impl GitObject for GitTree {
Expand Down

0 comments on commit d0fcfc8

Please # to comment.