From 1471897b84b43c467c753b5edebe636f835afc6a Mon Sep 17 00:00:00 2001 From: Devesh Kumar Singh Date: Fri, 3 Apr 2020 13:08:41 +0530 Subject: [PATCH] Improve check for svn version string --- news/7968.bugfix | 1 + src/pip/_internal/vcs/subversion.py | 15 +++++++++++++-- tests/unit/test_vcs.py | 12 ++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 news/7968.bugfix diff --git a/news/7968.bugfix b/news/7968.bugfix new file mode 100644 index 000000000..d6959730a --- /dev/null +++ b/news/7968.bugfix @@ -0,0 +1 @@ +Look for version string in the entire output of svn --version, not just the first line diff --git a/src/pip/_internal/vcs/subversion.py b/src/pip/_internal/vcs/subversion.py index 0ec659744..d0fe3cd9d 100644 --- a/src/pip/_internal/vcs/subversion.py +++ b/src/pip/_internal/vcs/subversion.py @@ -25,7 +25,7 @@ _svn_info_xml_url_re = re.compile(r'(.*)') if MYPY_CHECK_RUNNING: - from typing import Optional, Tuple + from typing import Optional, Tuple, Text from pip._internal.utils.subprocess import CommandArgs from pip._internal.utils.misc import HiddenText from pip._internal.vcs.versioncontrol import AuthInfo, RevOptions @@ -215,7 +215,18 @@ class Subversion(VersionControl): # svn, version 1.7.14 (r1542130) # compiled Mar 28 2018, 08:49:13 on x86_64-pc-linux-gnu version_prefix = 'svn, version ' - version = self.run_command(['--version'], show_stdout=False) + cmd_output = self.run_command(['--version'], show_stdout=False) + + # Split the output by newline, and find the first line where + # version_prefix is present + output_lines = cmd_output.split('\n') + version = '' # type: Text + + for line in output_lines: + if version_prefix in line: + version = line + break + if not version.startswith(version_prefix): return () diff --git a/tests/unit/test_vcs.py b/tests/unit/test_vcs.py index 590cb5c0b..166585db3 100644 --- a/tests/unit/test_vcs.py +++ b/tests/unit/test_vcs.py @@ -443,6 +443,18 @@ def test_subversion__call_vcs_version(): ('svn, version 1.10.3 (r1842928)\n' ' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0', (1, 10, 3)), + ('Warning: Failed to set locale category LC_NUMERIC to en_IN.\n' + 'Warning: Failed to set locale category LC_TIME to en_IN.\n' + 'svn, version 1.10.3 (r1842928)\n' + ' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0', + (1, 10, 3)), + ('Warning: Failed to set locale category LC_NUMERIC to en_IN.\n' + 'Warning: Failed to set locale category LC_TIME to en_IN.\n' + 'svn, version 1.10.3 (r1842928)\n' + ' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0' + 'svn, version 1.11.3 (r1842928)\n' + ' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0', + (1, 10, 3)), ('svn, version 1.9.7 (r1800392)', (1, 9, 7)), ('svn, version 1.9.7a1 (r1800392)', ()), ('svn, version 1.9 (r1800392)', (1, 9)),