Skip to content

Commit 1471897

Browse files
committed
Improve check for svn version string
1 parent 642fb07 commit 1471897

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

news/7968.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Look for version string in the entire output of svn --version, not just the first line

src/pip/_internal/vcs/subversion.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
if MYPY_CHECK_RUNNING:
28-
from typing import Optional, Tuple
28+
from typing import Optional, Tuple, Text
2929
from pip._internal.utils.subprocess import CommandArgs
3030
from pip._internal.utils.misc import HiddenText
3131
from pip._internal.vcs.versioncontrol import AuthInfo, RevOptions
@@ -215,7 +215,18 @@ def call_vcs_version(self):
215215
# svn, version 1.7.14 (r1542130)
216216
# compiled Mar 28 2018, 08:49:13 on x86_64-pc-linux-gnu
217217
version_prefix = 'svn, version '
218-
version = self.run_command(['--version'], show_stdout=False)
218+
cmd_output = self.run_command(['--version'], show_stdout=False)
219+
220+
# Split the output by newline, and find the first line where
221+
# version_prefix is present
222+
output_lines = cmd_output.split('\n')
223+
version = '' # type: Text
224+
225+
for line in output_lines:
226+
if version_prefix in line:
227+
version = line
228+
break
229+
219230
if not version.startswith(version_prefix):
220231
return ()
221232

tests/unit/test_vcs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,18 @@ def test_subversion__call_vcs_version():
443443
('svn, version 1.10.3 (r1842928)\n'
444444
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0',
445445
(1, 10, 3)),
446+
('Warning: Failed to set locale category LC_NUMERIC to en_IN.\n'
447+
'Warning: Failed to set locale category LC_TIME to en_IN.\n'
448+
'svn, version 1.10.3 (r1842928)\n'
449+
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0',
450+
(1, 10, 3)),
451+
('Warning: Failed to set locale category LC_NUMERIC to en_IN.\n'
452+
'Warning: Failed to set locale category LC_TIME to en_IN.\n'
453+
'svn, version 1.10.3 (r1842928)\n'
454+
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0'
455+
'svn, version 1.11.3 (r1842928)\n'
456+
' compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0',
457+
(1, 10, 3)),
446458
('svn, version 1.9.7 (r1800392)', (1, 9, 7)),
447459
('svn, version 1.9.7a1 (r1800392)', ()),
448460
('svn, version 1.9 (r1800392)', (1, 9)),

0 commit comments

Comments
 (0)