From ef927bef68c7ed556bd13d6f29a61e3e5ca354aa Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 25 Mar 2023 16:57:47 -0700 Subject: [PATCH] version: add a --builtin flag to display the recorded version This will be used by the maintainer commands in the todo branch. Signed-off-by: David Aguilar --- cola/main.py | 8 +++++++- cola/version.py | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cola/main.py b/cola/main.py index e7cac114..334bf45c 100644 --- a/cola/main.py +++ b/cola/main.py @@ -441,6 +441,12 @@ def add_tag_command(subparser): def add_version_command(subparser): parser = add_command(subparser, 'version', 'print the version', cmd_version) parser.add_argument( + '--builtin', + action='store_true', + default=False, + help=argparse.SUPPRESS, + ) + parser.add_argument( '--brief', action='store_true', default=False, @@ -602,7 +608,7 @@ def cmd_merge(args): def cmd_version(args): from . import version # pylint: disable=all - version.print_version(brief=args.brief) + version.print_version(builtin=args.builtin, brief=args.brief) return 0 diff --git a/cola/version.py b/cola/version.py index d518bf8b..280aba03 100644 --- a/cola/version.py +++ b/cola/version.py @@ -73,6 +73,11 @@ def version(): return pkg_version +def builtin_version(): + """Returns the version recorded in cola/_version.py""" + return VERSION + + @memoize def check_version(min_ver, ver): """Check whether ver is greater or equal to min_ver""" @@ -124,12 +129,15 @@ def git_version(context): def cola_version(): + """A version string for consumption by humans""" suffix = version() return 'cola version %s' % suffix -def print_version(brief=False): - if brief: +def print_version(builtin=False, brief=False): + if builtin: + msg = builtin_version() + elif brief: msg = version() else: msg = cola_version() -- 2.11.4.GIT