Skip to content

Commit 10f7084

Browse files
committed
Add unit tests for Git SSH parsing + remove a bug with explicit SSH URLs
1 parent fa13011 commit 10f7084

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

pip/vcs/git.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ def get_url_rev(self):
201201
url = url.replace('ssh://', '')
202202
else:
203203
url, rev = super(Git, self).get_url_rev()
204+
# For explicit SSH URLs, remove 'ssh://' to clone
205+
url = url.replace('ssh://', '')
204206

205207
return url, rev
206208

tests/unit/test_vcs.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,37 @@ def test_git_get_src_requirements():
3939
])
4040

4141

42+
def test_git_urls():
43+
"""
44+
Test git url support.
45+
46+
SSH has special handling.
47+
"""
48+
https_repo = Git(
49+
url='git+https://github.com/Eyepea/pip.git@8cf54fff31b650847e0cddc2cd2951c34e0b4822#egg=pip'
50+
)
51+
implicit_ssh_repo = Git(
52+
url='[email protected]:Eyepea/pip.git@8cf54fff31b650847e0cddc2cd2951c34e0b4822#egg=pip'
53+
)
54+
55+
explicit_ssh_repo = Git(
56+
url='git+ssh://[email protected]:Eyepea/pip.git@8cf54fff31b650847e0cddc2cd2951c34e0b4822#egg=pip'
57+
)
58+
59+
assert https_repo.get_url_rev() == (
60+
'https://github.com/Eyepea/pip.git',
61+
'8cf54fff31b650847e0cddc2cd2951c34e0b4822',
62+
)
63+
assert implicit_ssh_repo.get_url_rev() == (
64+
'[email protected]:Eyepea/pip.git',
65+
'8cf54fff31b650847e0cddc2cd2951c34e0b4822',
66+
)
67+
assert explicit_ssh_repo.get_url_rev() == (
68+
'[email protected]:Eyepea/pip.git',
69+
'8cf54fff31b650847e0cddc2cd2951c34e0b4822',
70+
)
71+
72+
4273
def test_translate_egg_surname():
4374
vc = VersionControl()
4475
assert vc.translate_egg_surname("foo") == "foo"

0 commit comments

Comments
 (0)