File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -77,14 +77,23 @@ pub enum Either<'buf, 'cache> {
7777}
7878
7979impl Either < ' _ , ' _ > {
80- /// Get a commits `tree_id` by either getting it from a [`gix_commitgraph::Graph`], if
80+ /// Get a commit’s `tree_id` by either getting it from a [`gix_commitgraph::Graph`], if
8181 /// present, or a [`gix_object::CommitRefIter`] otherwise.
8282 pub fn tree_id ( self ) -> Result < ObjectId , gix_object:: decode:: Error > {
8383 match self {
8484 Self :: CommitRefIter ( mut commit_ref_iter) => commit_ref_iter. tree_id ( ) ,
8585 Self :: CachedCommit ( commit) => Ok ( commit. root_tree_id ( ) . into ( ) ) ,
8686 }
8787 }
88+
89+ /// Get a commit’s `commit_time` by either getting it from a [`gix_commitgraph::Graph`], if
90+ /// present, or a [`gix_object::CommitRefIter`] otherwise.
91+ pub fn commit_time ( self ) -> Result < gix_date:: SecondsSinceUnixEpoch , gix_object:: decode:: Error > {
92+ match self {
93+ Self :: CommitRefIter ( commit_ref_iter) => commit_ref_iter. committer ( ) . map ( |c| c. seconds ( ) ) ,
94+ Self :: CachedCommit ( commit) => Ok ( commit. committer_timestamp ( ) as gix_date:: SecondsSinceUnixEpoch ) ,
95+ }
96+ }
8897}
8998
9099/// Find information about a commit by either getting it from a [`gix_commitgraph::Graph`], if
You can’t perform that action at this time.
0 commit comments