Restore repo state in checkoutBranch
If we pass a repo state to checkoutBranch, we should check out the repo/branch as specified by the repo state. FYI, there are two theoretical ways we could call checkoutBranch: 1) Without a repo state (in which case we would expect to checkout the current value of the branch in the repo; presumable this would be done after an update() call also without a repo state, which means the current branch would match upstream). 2) With a repo state, in which case we would expect to check out the branch as specified by the repo state. Currently Zuul only uses option 2. Change-Id: Icad68a337b3ff5fc80af32ee0a4845cc83daa14b
This commit is contained in:
parent
fc11cf1334
commit
397f708d56
|
@ -972,7 +972,8 @@ class TestMerger(ZuulTestCase):
|
|||
self.log.info('Update the repo and ensure it has updated properly')
|
||||
merger.updateRepo('gerrit', 'org/project1',
|
||||
repo_state=repo_state_update_branch_ff_rev)
|
||||
merger.checkoutBranch('gerrit', 'org/project1', 'master')
|
||||
merger.checkoutBranch('gerrit', 'org/project1', 'master',
|
||||
repo_state=repo_state_update_branch_ff_rev)
|
||||
repo = merger.getRepo('gerrit', 'org/project1')
|
||||
zuul_repo = git.Repo(repo.local_path)
|
||||
self.log.debug("Zuul master %s",
|
||||
|
@ -980,10 +981,9 @@ class TestMerger(ZuulTestCase):
|
|||
|
||||
# It's not important for the zuul ref to match; it's only used
|
||||
# to avoid garbage collection, so we don't check that here.
|
||||
# TODO: These shoud be equal; fix bug and reverse logic
|
||||
self.assertNotEqual(upstream_repo.commit('refs/heads/master').hexsha,
|
||||
self.assertEqual(upstream_repo.commit('refs/heads/master').hexsha,
|
||||
zuul_repo.commit('refs/heads/master').hexsha)
|
||||
self.assertNotEqual(upstream_repo.commit(change_ref).hexsha,
|
||||
self.assertEqual(upstream_repo.commit(change_ref).hexsha,
|
||||
zuul_repo.commit('refs/heads/master').hexsha)
|
||||
self.assertNotEqual(upstream_repo.commit(change_ref).hexsha,
|
||||
self.assertEqual(upstream_repo.commit(change_ref).hexsha,
|
||||
zuul_repo.commit('HEAD').hexsha)
|
||||
|
|
|
@ -849,6 +849,10 @@ class Merger(object):
|
|||
repo_state=repo_state,
|
||||
process_worker=process_worker,
|
||||
zuul_event_id=zuul_event_id)
|
||||
if repo_state:
|
||||
self._restoreRepoState(connection_name, project_name, repo,
|
||||
repo_state, zuul_event_id,
|
||||
process_worker=process_worker)
|
||||
repo.checkout(branch, zuul_event_id=zuul_event_id)
|
||||
|
||||
def _saveRepoState(self, connection_name, project_name, repo,
|
||||
|
|
Loading…
Reference in New Issue