Skip to content

Commit

Permalink
fix(changelog): set the previous release when using --unreleased (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Jan 23, 2022
1 parent 8bb48b0 commit 2be04f8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions git-cliff/src/lib.rs
Expand Up @@ -233,8 +233,10 @@ pub fn run(mut args: Opt) -> Result<()> {
}

// Set the previous release if needed.
if args.latest {
if let Some((commit_id, version)) = tags.get_index(tags.len() - 2) {
if args.latest || args.unreleased {
if let Some((commit_id, version)) =
tags.len().checked_sub(2).and_then(|v| tags.get_index(v))
{
let previous_release = Release {
commit_id: Some(commit_id.to_string()),
version: Some(version.to_string()),
Expand Down

0 comments on commit 2be04f8

Please sign in to comment.