[util] Resolve git+https URLs

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-05-16 07:51:13 +02:00
parent 4e3d87e658
commit d3900296af
2 changed files with 14 additions and 1 deletions

View File

@ -243,7 +243,11 @@ def resolve_git_url(url):
if not ref:
return url
baseurl = urlparse.urlunsplit((r.scheme, r.netloc, r.path, '', ''))
# Remove git+ prefix from scheme if present. This is for resolving only,
# the final result must use original scheme.
scheme = r.scheme.replace('git+', '')
baseurl = urlparse.urlunsplit((scheme, r.netloc, r.path, '', ''))
_, output = run(['git', 'ls-remote', baseurl, ref])
lines = [line for line in output.split('\n') if line]

View File

@ -68,6 +68,15 @@ class TestGitRefResolver(unittest.TestCase):
run.assert_called_once_with(['git', 'ls-remote', 'https://git.example.com/repo.git', 'HEAD'])
self.assertEqual(url, 'https://git.example.com/repo.git?#CAFEBABE')
@mock.patch('pungi.util.run')
def test_resolve_strip_git_plus_prefix(self, run):
run.return_value = (0, 'CAFEBABE\tHEAD\n')
url = util.resolve_git_url('git+https://git.example.com/repo.git#HEAD')
run.assert_called_once_with(['git', 'ls-remote', 'https://git.example.com/repo.git', 'HEAD'])
self.assertEqual(url, 'git+https://git.example.com/repo.git#CAFEBABE')
class TestGetVariantData(unittest.TestCase):
def test_get_simple(self):