mirror of
https://github.com/drewcassidy/yaclog.git
synced 2024-09-01 14:58:58 +00:00
Infer version number for unreleased versions
increment the patch number. not always whats intended but at least produces something unique
This commit is contained in:
parent
c4be5d2420
commit
2a67f6edc7
@ -70,7 +70,8 @@ def reformat(obj: Changelog):
|
|||||||
help='Show only the version body.')
|
help='Show only the version body.')
|
||||||
@click.option('--header', '-h', 'mode', flag_value='header',
|
@click.option('--header', '-h', 'mode', flag_value='header',
|
||||||
help='Show only the version header.')
|
help='Show only the version header.')
|
||||||
@click.option('--version', '-v', 'mode', flag_value='version', help='Show only the version number.')
|
@click.option('--version', '-v', 'mode', flag_value='version', help='Show only the version number. If the current version is unreleased, '
|
||||||
|
'this is inferred by incrementing the patch number of the last released version')
|
||||||
@click.argument('version_names', metavar='VERSIONS', type=str, nargs=-1)
|
@click.argument('version_names', metavar='VERSIONS', type=str, nargs=-1)
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def show(obj: Changelog, all_versions, markdown, mode, version_names):
|
def show(obj: Changelog, all_versions, markdown, mode, version_names):
|
||||||
@ -89,12 +90,18 @@ def show(obj: Changelog, all_versions, markdown, mode, version_names):
|
|||||||
}
|
}
|
||||||
|
|
||||||
str_func = functions[mode]
|
str_func = functions[mode]
|
||||||
|
kwargs = {'md': markdown, 'color': True}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if all_versions:
|
if all_versions:
|
||||||
versions = obj.versions
|
versions = obj.versions
|
||||||
elif len(version_names) == 0:
|
elif len(version_names) == 0:
|
||||||
versions = [obj.current_version()]
|
versions = [obj.current_version()]
|
||||||
|
if mode == 'version' and versions[0].name == 'Unreleased':
|
||||||
|
latest = obj.current_version(released=True).version
|
||||||
|
inferred = yaclog.version.increment_version(str(latest), 2, '')
|
||||||
|
print(str(inferred))
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
versions = [obj.get_version(name) for name in version_names]
|
versions = [obj.get_version(name) for name in version_names]
|
||||||
except KeyError as k:
|
except KeyError as k:
|
||||||
@ -102,8 +109,6 @@ def show(obj: Changelog, all_versions, markdown, mode, version_names):
|
|||||||
except ValueError as v:
|
except ValueError as v:
|
||||||
raise click.ClickException(str(v))
|
raise click.ClickException(str(v))
|
||||||
|
|
||||||
kwargs = {'md': markdown, 'color': True}
|
|
||||||
|
|
||||||
sep = '\n\n' if mode == 'body' or mode == 'full' else '\n'
|
sep = '\n\n' if mode == 'body' or mode == 'full' else '\n'
|
||||||
click.echo(sep.join([str_func(v, kwargs) for v in versions]))
|
click.echo(sep.join([str_func(v, kwargs) for v in versions]))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user