diff --git a/CHANGELOG.md b/CHANGELOG.md index f0f05f5..aaf6e71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file +## Unreleased + +### Changed + +- `release -c` will no longer create empty commits, and will use the current commit instead + ## 0.3.1 - 2021-04-24 ### Added diff --git a/yaclog/cli/__main__.py b/yaclog/cli/__main__.py index 8b84b13..b00d958 100644 --- a/yaclog/cli/__main__.py +++ b/yaclog/cli/__main__.py @@ -207,20 +207,27 @@ def release(obj: Changelog, v_flag, commit): repo.index.add(obj.path) version_type = '' if yaclog.cli.version_util.is_release(cur_version.name) else 'non-release ' + tracked = len(repo.index.diff(repo.head.commit)) + tracked_warning = 'Create tag' untracked = len(repo.index.diff(None)) untracked_warning = '' untracked_plural = 's' if untracked > 1 else '' if untracked > 0: untracked_warning = click.style( - f' You have {untracked} untracked file{untracked_plural} that will not be committed.', + f' You have {untracked} untracked file{untracked_plural} that will not be included.', fg='red', bold=True) - click.confirm(f'Commit and create tag for {version_type}version {cur_version.name}?{untracked_warning}', + if tracked > 0: + tracked_warning = 'Commit and create tag' + + click.confirm(f'{tracked_warning} for {version_type}version {cur_version.name}?{untracked_warning}', abort=True) - repo.index.commit(f'Version {cur_version.name}\n\n{cur_version.body()}') - repo.create_tag(cur_version.name, message=cur_version.body(False)) + if tracked > 0: + repo.index.commit(f'Version {cur_version.name}\n\n{cur_version.body()}') + print(f'Created commit {repo.head.commit.hexsha[0:7]}') + repo.create_tag(cur_version.name, message=cur_version.body(False)) print(f'Created tag "{cur_version.name}".')