Skip to content

Commit e41e8dd

Browse files
authored
fix(changelog): correctly set the tag message for the latest release (#854)
1 parent f3b067b commit e41e8dd

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

git-cliff/src/lib.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ fn process_repository<'a>(
239239
if let Some(commit_id) = commits.first().map(|c| c.id().to_string()) {
240240
match tags.get(&commit_id) {
241241
Some(tag) => {
242-
warn!("There is already a tag ({:?}) for {}", tag, commit_id);
242+
warn!("There is already a tag ({}) for {}", tag.name, commit_id);
243243
}
244244
None => {
245245
tags.insert(commit_id, repository.resolve_tag(tag));
@@ -302,13 +302,6 @@ fn process_repository<'a>(
302302
.extend(custom_commits.iter().cloned().map(Commit::from));
303303
}
304304

305-
// Set custom message for the latest release.
306-
if let Some(message) = &args.with_tag_message {
307-
if let Some(latest_release) = releases.iter_mut().last() {
308-
latest_release.message = Some(message.to_owned());
309-
}
310-
}
311-
312305
// Set the previous release if the first release does not have one set.
313306
if releases[0]
314307
.previous
@@ -343,6 +336,17 @@ fn process_repository<'a>(
343336
}
344337
}
345338

339+
// Set custom message for the latest release.
340+
if let Some(message) = &args.with_tag_message {
341+
if let Some(latest_release) = releases
342+
.iter_mut()
343+
.filter(|release| !release.commits.is_empty())
344+
.last()
345+
{
346+
latest_release.message = Some(message.to_owned());
347+
}
348+
}
349+
346350
Ok(releases)
347351
}
348352

0 commit comments

Comments
 (0)