Skip to content

Commit

Permalink
feat: Object::peel_to_tree() as convenience method. (#470)
Browse files Browse the repository at this point in the history
It's very common to try to work with trees, so let's make that easier.
  • Loading branch information
Byron committed Sep 20, 2022
1 parent 0ac4a2c commit 0871a96
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion git-repository/src/object/peel.rs
Expand Up @@ -2,7 +2,7 @@
use crate::{
object,
object::{peel, Kind},
Object,
Object, Tree,
};

///
Expand Down Expand Up @@ -67,6 +67,11 @@ impl<'repo> Object<'repo> {
}
}

/// Peel this object into a tree and return it, if this is possible.
pub fn peel_to_tree(self) -> Result<Tree<'repo>, peel::to_kind::Error> {
Ok(self.peel_to_kind(git_object::Kind::Tree)?.into_tree())
}

// TODO: tests
/// Follow all tag object targets until a commit, tree or blob is reached.
///
Expand Down

0 comments on commit 0871a96

Please sign in to comment.