From d0e991e892eb45c9de172fbb3987f9ae32ddfc3f Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Mon, 1 Mar 2021 09:14:56 -0800 Subject: Clarify CLI version number as core version (#72287) * clarify CLI version number as core version * reduce confusion with `ansible` PyPI package >= 2.10 drifting from core version * fix units --- changelogs/fragments/core_version.yml | 2 ++ lib/ansible/cli/arguments/option_helpers.py | 2 +- test/units/cli/arguments/test_optparse_helpers.py | 2 +- test/units/cli/test_adhoc.py | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/core_version.yml diff --git a/changelogs/fragments/core_version.yml b/changelogs/fragments/core_version.yml new file mode 100644 index 0000000000..0575a9b3f9 --- /dev/null +++ b/changelogs/fragments/core_version.yml @@ -0,0 +1,2 @@ +minor_changes: +- CLI version displays clarified as core version diff --git a/lib/ansible/cli/arguments/option_helpers.py b/lib/ansible/cli/arguments/option_helpers.py index 043b7b5d48..733645b02c 100644 --- a/lib/ansible/cli/arguments/option_helpers.py +++ b/lib/ansible/cli/arguments/option_helpers.py @@ -157,7 +157,7 @@ def _gitinfo(): def version(prog=None): """ return ansible version """ if prog: - result = [" ".join((prog, __version__))] + result = ["{0} [core {1}] ".format(prog, __version__)] else: result = [__version__] diff --git a/test/units/cli/arguments/test_optparse_helpers.py b/test/units/cli/arguments/test_optparse_helpers.py index 894f3bf8c8..082c9be4dc 100644 --- a/test/units/cli/arguments/test_optparse_helpers.py +++ b/test/units/cli/arguments/test_optparse_helpers.py @@ -25,7 +25,7 @@ VERSION_OUTPUT = opt_help.version(prog=FAKE_PROG) @pytest.mark.parametrize( 'must_have', [ - FAKE_PROG + u' %s' % ansible_version, + FAKE_PROG + u' [core %s]' % ansible_version, u'config file = %s' % C.CONFIG_FILE, u'configured module search path = %s' % cpath, u'ansible python module location = %s' % ':'.join(ansible_path), diff --git a/test/units/cli/test_adhoc.py b/test/units/cli/test_adhoc.py index 75cbc32713..bb2ed16527 100644 --- a/test/units/cli/test_adhoc.py +++ b/test/units/cli/test_adhoc.py @@ -105,7 +105,7 @@ def test_ansible_version(capsys, mocker): version_lines = version[0].splitlines() assert len(version_lines) == 9, 'Incorrect number of lines in "ansible --version" output' - assert re.match('ansible [0-9.a-z]+(?: .*)?$', version_lines[0]), 'Incorrect ansible version line in "ansible --version" output' + assert re.match(r'ansible \[core [0-9.a-z]+\]', version_lines[0]), 'Incorrect ansible version line in "ansible --version" output' assert re.match(' config file = .*$', version_lines[1]), 'Incorrect config file line in "ansible --version" output' assert re.match(' configured module search path = .*$', version_lines[2]), 'Incorrect module search path in "ansible --version" output' assert re.match(' ansible python module location = .*$', version_lines[3]), 'Incorrect python module location in "ansible --version" output' -- cgit v1.2.3