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> {
77
77
}
78
78
79
79
impl 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
81
81
/// present, or a [`gix_object::CommitRefIter`] otherwise.
82
82
pub fn tree_id ( self ) -> Result < ObjectId , gix_object:: decode:: Error > {
83
83
match self {
84
84
Self :: CommitRefIter ( mut commit_ref_iter) => commit_ref_iter. tree_id ( ) ,
85
85
Self :: CachedCommit ( commit) => Ok ( commit. root_tree_id ( ) . into ( ) ) ,
86
86
}
87
87
}
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
+ }
88
97
}
89
98
90
99
/// 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