From 3972786d827025ed0ce009a749ceac3cc1b9edcb Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Sun, 25 Apr 2021 22:20:42 -0700 Subject: [PATCH] Fix release command and empty logs --- CHANGELOG.md | 1 + yaclog/cli/__main__.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85fe4b1..23c3fbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file - Changelog links dict now contains version links. Modified version links will overwrite those in the table when writing to a file - Changelog object no longer errors when creating without a path. - `release` now resets lesser version values when incrementing +- `release` now works with logs that have only unreleased changes ## 0.3.2 - 2021-04-24 diff --git a/yaclog/cli/__main__.py b/yaclog/cli/__main__.py index 07f1ae3..2878527 100644 --- a/yaclog/cli/__main__.py +++ b/yaclog/cli/__main__.py @@ -181,13 +181,18 @@ def entry(obj: Changelog, bullets, paragraphs, section_name, version_name): @click.pass_obj def release(obj: Changelog, v_flag, commit): """Release versions in the changelog and increment their version numbers""" - version = [v for v in obj.versions if v.name.lower() != 'unreleased'][0] + matches = [v for v in obj.versions if v.name.lower() != 'unreleased'] + if len(matches) == 0: + version = '0.0.0' + else: + version = matches[0].name + cur_version = obj.versions[0] old_name = cur_version.name if v_flag: if v_flag[0] == '+': - new_name = yaclog.cli.version_util.increment_version(version.name, v_flag) + new_name = yaclog.cli.version_util.increment_version(version, v_flag) else: new_name = v_flag