Avoid ref parsing when creating heads
In case a branch name contained the '@' character this was interpreted by Gitpython according to the format supported by git-rev-parse when resolving the ref name. Since we already have the commit for the ref we can use it directly, that way avoiding any issues caused by parsing the ref name. Change-Id: I49665c62389245f937317e70f093d33a4bf759d3
This commit is contained in:
parent
1dbcfd5346
commit
5cab847b2f
|
@ -48,6 +48,21 @@ class TestMergerRepo(ZuulTestCase):
|
|||
self.assertIn('refs/heads/foobar', repo.branches)
|
||||
self.assertNotIn('refs/heads/refs/heads/foobar', repo.branches)
|
||||
|
||||
def test_create_head_at_char(self):
|
||||
"""Test that we can create branches containing the '@' char.
|
||||
|
||||
This is a regression test to make sure we are not using GitPython
|
||||
APIs that interpret the '@' as a special char.
|
||||
"""
|
||||
parent_path = os.path.join(self.upstream_root, 'org/project1')
|
||||
parent_repo = git.Repo(parent_path)
|
||||
parent_repo.create_head("refs/heads/foo@bar")
|
||||
|
||||
work_repo = Repo(parent_path, self.workspace_root,
|
||||
'none@example.org', 'User Name', '0', '0')
|
||||
repo = work_repo.createRepoObject(None)
|
||||
self.assertIn('foo@bar', repo.branches)
|
||||
|
||||
def test_ensure_cloned(self):
|
||||
parent_path = os.path.join(self.upstream_root, 'org/project1')
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ class Repo(object):
|
|||
if ref.remote_head == 'HEAD':
|
||||
continue
|
||||
repo.create_head('refs/heads/' + ref.remote_head,
|
||||
ref,
|
||||
ref.commit,
|
||||
force=True)
|
||||
with repo.config_writer() as config_writer:
|
||||
if self.email:
|
||||
|
@ -386,7 +386,9 @@ class Repo(object):
|
|||
for ref in origin.refs:
|
||||
if ref.remote_head == 'HEAD':
|
||||
continue
|
||||
repo.create_head('refs/heads/' + ref.remote_head, ref, force=True)
|
||||
repo.create_head('refs/heads/' + ref.remote_head,
|
||||
ref.commit,
|
||||
force=True)
|
||||
return messages
|
||||
|
||||
def reset(self, zuul_event_id=None, build=None, process_worker=None):
|
||||
|
|
Loading…
Reference in New Issue