Skip to content

Commit

Permalink
feat: Add support for showing unreleased changelog
Browse files Browse the repository at this point in the history
Fixes #134
  • Loading branch information
relekang committed Aug 5, 2019
1 parent 14abb05 commit 41ef794
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion semantic_release/cli.py
Expand Up @@ -110,7 +110,10 @@ def changelog(**kwargs):
previous_version = get_previous_version(current_version)
debug('changelog got previous_version', previous_version)

log = generate_changelog(previous_version, current_version)
if kwargs['unreleased']:
log = generate_changelog(current_version, None)
else:
log = generate_changelog(previous_version, current_version)
click.echo(markdown_changelog(current_version, log, header=False))

debug('noop={}, post={}'.format(kwargs.get('noop'), kwargs.get('post')))
Expand Down Expand Up @@ -244,6 +247,10 @@ def cmd_publish(**kwargs):

@main.command(name='changelog', help=changelog.__doc__)
@common_options
@click.option(
'--unreleased/--released',
help="Decides whether to show the released or unreleased changelog."
)
def cmd_changelog(**kwargs):
try:
return changelog(**kwargs)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_cli.py
Expand Up @@ -259,4 +259,5 @@ def test_changelog_should_call_functions(mocker, runner):
mock_changelog = mocker.patch('semantic_release.cli.changelog', return_value=True)
result = runner.invoke(main, ['changelog'])
assert result.exit_code == 0
mock_changelog.assert_called_once_with(noop=False, post=False, force_level=None, retry=False)
mock_changelog.assert_called_once_with(
noop=False, post=False, force_level=None, retry=False, unreleased=False)

0 comments on commit 41ef794

Please sign in to comment.