Skip to content

Commit 24169d5

Browse files
committed
fix: use committer timestamp for commit_duration_days calculation
Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>
1 parent 085b2fe commit 24169d5

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

git-cliff-core/src/commit.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ impl Range {
123123
pub struct Commit<'a> {
124124
/// Commit ID.
125125
pub id: String,
126-
/// Timestamp of the commit in seconds, from epoch.
127-
pub timestamp: i64,
128126
/// Commit message including title, description and summary.
129127
pub message: String,
130128
/// Conventional commit.
@@ -202,7 +200,6 @@ impl From<&GitCommit<'_>> for Commit<'_> {
202200
fn from(commit: &GitCommit<'_>) -> Self {
203201
Commit {
204202
id: commit.id().to_string(),
205-
timestamp: commit.time().seconds(),
206203
message: commit.message().unwrap_or_default().trim_end().to_string(),
207204
author: commit.author().into(),
208205
committer: commit.committer().into(),
@@ -467,7 +464,6 @@ impl Serialize for Commit<'_> {
467464

468465
let mut commit = serializer.serialize_struct("Commit", 20)?;
469466
commit.serialize_field("id", &self.id)?;
470-
commit.serialize_field("timestamp", &self.timestamp)?;
471467
if let Some(conv) = &self.conv {
472468
commit.serialize_field("message", conv.description())?;
473469
commit.serialize_field("body", &conv.body())?;

git-cliff-core/src/release.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ impl Release<'_> {
147147
} else {
148148
self.commits
149149
.iter()
150-
.min_by_key(|c| c.timestamp)
151-
.zip(self.commits.iter().max_by_key(|c| c.timestamp))
150+
.min_by_key(|c| c.committer.timestamp)
151+
.zip(self.commits.iter().max_by_key(|c| c.committer.timestamp))
152152
.and_then(|(first, last)| {
153-
Utc.timestamp_opt(first.timestamp, 0)
153+
Utc.timestamp_opt(first.committer.timestamp, 0)
154154
.single()
155-
.zip(Utc.timestamp_opt(last.timestamp, 0).single())
155+
.zip(Utc.timestamp_opt(last.committer.timestamp, 0).single())
156156
.map(|(start, end)| {
157157
(end.date_naive() - start.date_naive()).num_days() as i32
158158
})

0 commit comments

Comments
 (0)