mirror of
https://github.com/drewcassidy/yaclog.git
synced 2024-09-01 14:58:58 +00:00
Add -s, -n, and -y options to release
This commit is contained in:
parent
0666f7f593
commit
72126c8dca
@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file
|
All notable changes to this project will be documented in this file
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- added the `-s` option to `yaclog release` to increment arbitrary version segments
|
||||||
|
- added the `-n` option to `yaclog release` to create a new release instead of releasing a new one
|
||||||
|
- added the `-y` option to `yaclog release` to answer "yes" to all confirmation dialogs. Use with caution!
|
||||||
|
|
||||||
|
|
||||||
## Version 1.1.2 - 2022-12-29
|
## Version 1.1.2 - 2022-12-29
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -153,6 +153,11 @@ class TestRelease(unittest.TestCase):
|
|||||||
self.assertEqual(yaclog.read(location).versions[0].name, '1.0.1')
|
self.assertEqual(yaclog.read(location).versions[0].name, '1.0.1')
|
||||||
self.assertIn('1.0.1', result.output)
|
self.assertIn('1.0.1', result.output)
|
||||||
|
|
||||||
|
result = runner.invoke(cli, ['release', '-y', '-s', 2])
|
||||||
|
check_result(self, result)
|
||||||
|
self.assertEqual(yaclog.read(location).versions[0].name, '1.0.2')
|
||||||
|
self.assertIn('1.0.2', result.output)
|
||||||
|
|
||||||
runner.invoke(cli, ['entry', '-b', 'entry number 3'])
|
runner.invoke(cli, ['entry', '-b', 'entry number 3'])
|
||||||
|
|
||||||
result = runner.invoke(cli, ['release', '-m'])
|
result = runner.invoke(cli, ['release', '-m'])
|
||||||
@ -194,6 +199,12 @@ class TestRelease(unittest.TestCase):
|
|||||||
self.assertEqual(yaclog.read(location).versions[0].name, '3.0.0')
|
self.assertEqual(yaclog.read(location).versions[0].name, '3.0.0')
|
||||||
self.assertIn('3.0.0', result.output)
|
self.assertIn('3.0.0', result.output)
|
||||||
|
|
||||||
|
result = runner.invoke(cli, ['release', '-p', '-n'])
|
||||||
|
check_result(self, result)
|
||||||
|
self.assertEqual(yaclog.read(location).versions[0].name, '3.0.1')
|
||||||
|
self.assertEqual(yaclog.read(location).versions[1].name, '3.0.0')
|
||||||
|
self.assertIn('3.0.1', result.output)
|
||||||
|
|
||||||
def test_commit(self):
|
def test_commit(self):
|
||||||
"""Test committing and tagging releases"""
|
"""Test committing and tagging releases"""
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -187,6 +187,8 @@ def entry(obj: Changelog, bullets, paragraphs, section_name, version_name):
|
|||||||
help='Increment minor version number.')
|
help='Increment minor version number.')
|
||||||
@click.option('-p', '--patch', 'rel_seg', flag_value=2, type=int,
|
@click.option('-p', '--patch', 'rel_seg', flag_value=2, type=int,
|
||||||
help='Increment patch number.')
|
help='Increment patch number.')
|
||||||
|
@click.option('-s', '--segment', 'rel_seg', type=int,
|
||||||
|
help='Increment nth segment of the version. For example, `--segment 2` is equivalent to `--patch`')
|
||||||
@click.option('-a', '--alpha', 'pre_seg', flag_value='a', type=str, default=None,
|
@click.option('-a', '--alpha', 'pre_seg', flag_value='a', type=str, default=None,
|
||||||
help='Increment alpha version number.')
|
help='Increment alpha version number.')
|
||||||
@click.option('-b', '--beta', 'pre_seg', flag_value='b', type=str,
|
@click.option('-b', '--beta', 'pre_seg', flag_value='b', type=str,
|
||||||
@ -200,9 +202,13 @@ def entry(obj: Changelog, bullets, paragraphs, section_name, version_name):
|
|||||||
'If there are no changes to commit, the current commit will be tagged instead.')
|
'If there are no changes to commit, the current commit will be tagged instead.')
|
||||||
@click.option('-C', '--cargo', '-🦀', is_flag=True,
|
@click.option('-C', '--cargo', '-🦀', is_flag=True,
|
||||||
help='Update the version in a Rust cargo.toml manifest file.')
|
help='Update the version in a Rust cargo.toml manifest file.')
|
||||||
|
@click.option('-y', '--yes', is_flag=True,
|
||||||
|
help='Answer "yes" to all confirmation dialogs')
|
||||||
|
@click.option('-n', '--new', is_flag=True,
|
||||||
|
help = 'Create a new version instead of renaming an existing one')
|
||||||
@click.argument('version_name', metavar='VERSION', type=str, default=None, required=False)
|
@click.argument('version_name', metavar='VERSION', type=str, default=None, required=False)
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
|
def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo, yes, new):
|
||||||
"""
|
"""
|
||||||
Release VERSION, or a version incremented from the last release.
|
Release VERSION, or a version incremented from the last release.
|
||||||
|
|
||||||
@ -218,7 +224,10 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
|
|||||||
click.echo('Nothing to release!')
|
click.echo('Nothing to release!')
|
||||||
raise click.Abort
|
raise click.Abort
|
||||||
|
|
||||||
cur_version = obj.current_version()
|
if new:
|
||||||
|
cur_version = obj.add_version()
|
||||||
|
else:
|
||||||
|
cur_version = obj.current_version()
|
||||||
old_name = cur_version.name
|
old_name = cur_version.name
|
||||||
|
|
||||||
if version_name:
|
if version_name:
|
||||||
@ -235,11 +244,11 @@ def release(obj: Changelog, version_name, rel_seg, pre_seg, commit, cargo):
|
|||||||
new_name = yaclog.version.increment_version(new_name, rel_seg, pre_seg)
|
new_name = yaclog.version.increment_version(new_name, rel_seg, pre_seg)
|
||||||
|
|
||||||
if new_name != old_name:
|
if new_name != old_name:
|
||||||
if yaclog.version.is_release(old_name):
|
if yaclog.version.is_release(old_name) and not yes:
|
||||||
click.confirm(
|
click.confirm(
|
||||||
f"Rename release version {click.style(old_name, fg='blue')} "
|
f"Rename release version {click.style(old_name, fg='blue')} "
|
||||||
f"to {click.style(new_name, fg='blue')}?",
|
f"to {click.style(new_name, fg='blue')}?",
|
||||||
abort=True)
|
abort=True)
|
||||||
|
|
||||||
cur_version.name = new_name
|
cur_version.name = new_name
|
||||||
cur_version.date = datetime.datetime.utcnow().date()
|
cur_version.date = datetime.datetime.utcnow().date()
|
||||||
|
Loading…
Reference in New Issue
Block a user