Merge "gerrit: fix invalid ref computation from change"
This commit is contained in:
commit
d12e582148
|
@ -411,7 +411,9 @@ class FakeGerritChange(object):
|
|||
if parent is None:
|
||||
parent = 'refs/tags/init'
|
||||
ref = GerritChangeReference.create(
|
||||
repo, '1/%s/%s' % (self.number, self.latest_patchset),
|
||||
repo, '%s/%s/%s' % (str(self.number).zfill(2)[-2:],
|
||||
self.number,
|
||||
self.latest_patchset),
|
||||
parent)
|
||||
repo.head.reference = ref
|
||||
zuul.merger.merger.reset_repo_to_head(repo)
|
||||
|
@ -466,8 +468,9 @@ class FakeGerritChange(object):
|
|||
'createdOn': time.time(),
|
||||
'files': ps_files,
|
||||
'number': str(self.latest_patchset),
|
||||
'ref': 'refs/changes/1/%s/%s' % (self.number,
|
||||
self.latest_patchset),
|
||||
'ref': 'refs/changes/%s/%s/%s' % (str(self.number).zfill(2)[-2:],
|
||||
self.number,
|
||||
self.latest_patchset),
|
||||
'revision': c.hexsha,
|
||||
'uploader': {'email': 'user@example.com',
|
||||
'name': 'User name',
|
||||
|
|
|
@ -385,7 +385,7 @@ class TestExecutorRepos(ZuulTestCase):
|
|||
# one to make sure that our post job runs with the one that we
|
||||
# intended rather than simply the current repo state.
|
||||
B = self.fake_gerrit.addFakeChange('org/project1', 'master', 'B',
|
||||
parent='refs/changes/1/1/1')
|
||||
parent='refs/changes/01/1/1')
|
||||
B.setMerged()
|
||||
B_commit = str(upstream[p1].commit('master'))
|
||||
self.log.debug("B commit: %s" % B_commit)
|
||||
|
|
|
@ -469,7 +469,7 @@ class TestMergerRepo(ZuulTestCase):
|
|||
'''Tests that git gc doesn't prune FETCH_HEAD'''
|
||||
parent_path = os.path.join(self.upstream_root, 'org/project1')
|
||||
repo = git.Repo(parent_path)
|
||||
change_ref = 'refs/changes/1/1'
|
||||
change_ref = 'refs/changes/01/1'
|
||||
|
||||
self.log.info('Creating a commit on %s', change_ref)
|
||||
repo.head.reference = repo.head.commit
|
||||
|
|
|
@ -1966,7 +1966,7 @@ class TestScheduler(ZuulTestCase):
|
|||
# Validate node has recorded the failed job
|
||||
if change != "":
|
||||
ref = "refs/changes/%s/%s/.*" % (
|
||||
str(change_obj.number)[-1:], str(change_obj.number)
|
||||
str(change_obj.number).zfill(2)[-2:], str(change_obj.number)
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
|
@ -2041,7 +2041,8 @@ class TestScheduler(ZuulTestCase):
|
|||
|
||||
_fail_job_and_verify_autohold_request(A, ref)
|
||||
|
||||
ref = "refs/changes/%s/%s/.*" % (str(change)[-1:], str(change))
|
||||
ref = "refs/changes/%s/%s/.*" % (str(change).zfill(2)[-2:],
|
||||
str(change))
|
||||
_fail_job_and_verify_autohold_request(A, ref)
|
||||
_fail_job_and_verify_autohold_request(A, ".*")
|
||||
|
||||
|
@ -6934,8 +6935,8 @@ class TestSchedulerMerges(ZuulTestCase):
|
|||
'initial commit',
|
||||
'add content from fixture',
|
||||
# the intermediate commits order is nondeterministic
|
||||
"Merge commit 'refs/changes/1/2/1' of %s into HEAD" % us_path,
|
||||
"Merge commit 'refs/changes/1/3/1' of %s into HEAD" % us_path,
|
||||
"Merge commit 'refs/changes/02/2/1' of %s into HEAD" % us_path,
|
||||
"Merge commit 'refs/changes/03/3/1' of %s into HEAD" % us_path,
|
||||
]
|
||||
result = self._test_project_merge_mode(mode)
|
||||
self.assertEqual(result[:2], expected_messages[:2])
|
||||
|
|
|
@ -2242,7 +2242,7 @@ class TestInRepoConfig(ZuulTestCase):
|
|||
'playbooks/project-test1.yaml': in_repo_playbook}
|
||||
C = self.fake_gerrit.addFakeChange('org/project1', 'master', 'C',
|
||||
files=file_dict,
|
||||
parent='refs/changes/1/1/1')
|
||||
parent='refs/changes/01/1/1')
|
||||
C.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % (
|
||||
C.subject, B.data['id'])
|
||||
self.fake_gerrit.addEvent(C.getPatchsetCreatedEvent(1))
|
||||
|
|
|
@ -149,7 +149,7 @@ class GerritSource(BaseSource):
|
|||
return [f]
|
||||
|
||||
def getRefForChange(self, change):
|
||||
partial = change[-2:]
|
||||
partial = str(change).zfill(2)[-2:]
|
||||
return "refs/changes/%s/%s/.*" % (partial, change)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue