Keep empty query string in resolved git url
Pagure: #152 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
284d3a3510
commit
826afdc162
@ -243,7 +243,11 @@ def resolve_git_url(url):
|
||||
raise RuntimeError('Failed to resolve %s', url)
|
||||
|
||||
fragment = lines[0].split()[0]
|
||||
return urlparse.urlunsplit((r.scheme, r.netloc, r.path, r.query, fragment))
|
||||
result = urlparse.urlunsplit((r.scheme, r.netloc, r.path, r.query, fragment))
|
||||
if '?#' in url:
|
||||
# The urlparse library drops empty query string. This hack puts it back in.
|
||||
result = result.replace('#', '?#')
|
||||
return result
|
||||
|
||||
|
||||
# fomat: {arch|*: [data]}
|
||||
|
@ -48,6 +48,15 @@ class TestGitRefResolver(unittest.TestCase):
|
||||
|
||||
run.assert_called_once_with(['git', 'ls-remote', 'https://git.example.com/repo.git', 'HEAD'])
|
||||
|
||||
@mock.patch('pungi.util.run')
|
||||
def test_resolve_keep_empty_query_string(self, run):
|
||||
run.return_value = (0, 'CAFEBABE\tHEAD\n')
|
||||
|
||||
url = util.resolve_git_url('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, 'https://git.example.com/repo.git?#CAFEBABE')
|
||||
|
||||
|
||||
class TestGetVariantData(unittest.TestCase):
|
||||
def test_get_simple(self):
|
||||
|
Loading…
Reference in New Issue
Block a user