Skip to content

Commit

Permalink
Improve check for svn version string
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshks committed May 23, 2020
1 parent 642fb07 commit 1471897
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/7968.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Look for version string in the entire output of svn --version, not just the first line
15 changes: 13 additions & 2 deletions src/pip/_internal/vcs/subversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


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
Expand Down Expand Up @@ -215,7 +215,18 @@ def call_vcs_version(self):
# 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 ()

Expand Down
12 changes: 12 additions & 0 deletions tests/unit/test_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 1471897

Please sign in to comment.