From c0a02a32ea4ab97e7ce718dbec16f0840d27a582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 15 Sep 2024 18:35:04 +0200 Subject: [PATCH] fix(changelog): correctly set the tag message for the latest release --- git-cliff/src/lib.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index 95a36d9e38..2767847c45 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -239,7 +239,7 @@ fn process_repository<'a>( if let Some(commit_id) = commits.first().map(|c| c.id().to_string()) { match tags.get(&commit_id) { Some(tag) => { - warn!("There is already a tag ({:?}) for {}", tag, commit_id); + warn!("There is already a tag ({}) for {}", tag.name, commit_id); } None => { tags.insert(commit_id, repository.resolve_tag(tag)); @@ -302,13 +302,6 @@ fn process_repository<'a>( .extend(custom_commits.iter().cloned().map(Commit::from)); } - // Set custom message for the latest release. - if let Some(message) = &args.with_tag_message { - if let Some(latest_release) = releases.iter_mut().last() { - latest_release.message = Some(message.to_owned()); - } - } - // Set the previous release if the first release does not have one set. if releases[0] .previous @@ -343,6 +336,17 @@ fn process_repository<'a>( } } + // Set custom message for the latest release. + if let Some(message) = &args.with_tag_message { + if let Some(latest_release) = releases + .iter_mut() + .filter(|release| !release.commits.is_empty()) + .last() + { + latest_release.message = Some(message.to_owned()); + } + } + Ok(releases) }