From 2bc3745e8740fb912fa4fa76f4b0bc806f4327d6 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 29 Dec 2022 00:31:30 +0000 Subject: [PATCH] feat(bump-version): add --actions option --- tools/bump_version.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/bump_version.py b/tools/bump_version.py index 3c12aba0b..937368eec 100755 --- a/tools/bump_version.py +++ b/tools/bump_version.py @@ -259,9 +259,12 @@ def main() -> int | None: bumper = Bumper(packages[opt.package], bump_level=opt.level) logger.info("current version: %s", bumper.current_version) logger.info("bumping to version: %s", bumper.want_version) - if not opt.dry_run: + + if opt.actions is None or Action.UPDATE in opt.actions: bumper.update_files() + if opt.actions is None or Action.COMMIT in opt.actions: bumper.commit() + if opt.actions is None or Action.TAG in opt.actions: if opt.level != BumpLevel.DEV: bumper.create_tag() @@ -275,18 +278,26 @@ class BumpLevel(str, Enum): DEV = "dev" +class Action(str, Enum): + UPDATE = "update" + COMMIT = "commit" + TAG = "tag" + + def parse_cmdline() -> Namespace: parser = ArgumentParser(description=__doc__) parser.add_argument( + "-l", "--level", - choices=[level.value for level in BumpLevel], + choices=[m.value for m in BumpLevel], default=BumpLevel.PATCH.value, type=BumpLevel, help="the level to bump [default: %(default)s]", ) parser.add_argument( + "-p", "--package", choices=list(packages.keys()), default="psycopg", @@ -294,10 +305,11 @@ def parse_cmdline() -> Namespace: ) parser.add_argument( - "-n", - "--dry-run", - help="Just pretend", - action="store_true", + "-a", + "--actions", + help="The actions to perform [default: all]", + nargs="*", + choices=[m.value for m in Action], ) g = parser.add_mutually_exclusive_group() -- 2.47.2