From 9f5663ed83d83c7335b346313837d4cada9cd846 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 2 Feb 2022 22:45:16 +0800 Subject: [PATCH] feat: `easy::Commit::time()` to access the committers time conveniently. (#293) --- git-repository/src/easy/object/commit.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-repository/src/easy/object/commit.rs b/git-repository/src/easy/object/commit.rs index 185d962b56..7a700fa83c 100644 --- a/git-repository/src/easy/object/commit.rs +++ b/git-repository/src/easy/object/commit.rs @@ -31,6 +31,12 @@ impl<'repo> Commit<'repo> { pub fn message_raw(&self) -> Result<&'_ BStr, git_object::decode::Error> { Ok(self.decode()?.message) } + /// Decode the commit and obtain the time at which the commit was created. + /// + /// For the time at which it was authored, refer to `.decode()?.author.time`. + pub fn time(&self) -> Result { + Ok(self.decode()?.committer.time) + } /// Decode the entire commit object and return it for accessing all commit information. ///