1use chrono::{DateTime, Utc};
2use git2::Commit;
3
4pub struct KitCommit {
5 pub id: String,
6 pub email: String,
7 pub date: Option<DateTime<Utc>>,
8 pub time_seconds: i64,
9}
10
11impl KitCommit {
12 pub fn from_git2(commit: &Commit) -> Self {
13 let time_seconds = commit.time().seconds();
14 let date = Self::to_date(commit);
15 Self {
16 id: commit.id().to_string(),
17 email: commit.author().email().unwrap_or("Unknown").to_string(),
18 date,
19 time_seconds,
20 }
21 }
22
23 fn to_date(commit: &Commit) -> Option<DateTime<Utc>> {
24 DateTime::from_timestamp_secs(commit.time().seconds())
25 }
26}