Skip to content

Commit

Permalink
fix(changelog): correctly set the tag message for the latest release (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun authored Sep 17, 2024
1 parent f3b067b commit e41e8dd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit e41e8dd

Please sign in to comment.